mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
Hi !

I want to script a eBay-time-script, that reads the actual ebay time and can say it me in mIRC status. How can I read the eBay-Site?
This following script does not really work:


alias socket {
sockopen ebaysock 66.135.198.57 8080
echo 15 -s Socket opening...
}

on *:SOCKOPEN:ebaysock: {
echo 15 -s Sockopen...
sockwrite -n $sockname GET http://cgi3.ebay.de/aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.0 $+ $crlf $+ $crlf
echo 15 -s Socket is open.
}

on *:SOCKREAD:ebaysock: {
echo 15 -s Sockread...
var %stuff
sockread %stuff
echo 15 -s Socket is read.
if (%stuff != $null) {
echo 15 -s *** %stuff
timerebaysocketcloser 1 5 sockclose $sockname | echo 4 -s Socket closed.
}
}

on *:SOCKCLOSE:ebaysock:{
echo 4 -s Socket closed by eBay.
}

Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
I think the "?TimeShow"-part has to be sended some other way, can't remember how as I haven't messed with sockets/HTTP protocol, but you should be able to find it from some RFC


Code:
//if ( khaled isgod ) echo yes | else echo no
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
that isn't the syntax for the GET method.

GET /[filename[?querystring]]

You do NOT include http:// or the host, if you want to specify a host, you do it using the Host: header, not through your GET request. I suggest you read the HTTP1.0 and HTTP1.1 RFCs at http://www.rfc-editor.org/cgi-bin/rfcdoc...file_format=txt and http://www.rfc-editor.org/cgi-bin/rfcdoc...file_format=txt respectively.

Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
mh, it doesn't work?! Is this right ???

sockwrite -n $sockname GET /cgi3.ebay.de/aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.0 $+ $crlf $+ $crlf

In the status window there is the follow error text:

Socket opening...
Sockopen...
-
* /sockwrite: 'ebaysock' not connected (line 21, socket.mrc)
-

Joined: Apr 2003
Posts: 1
J
Mostly harmless
Offline
Mostly harmless
J
Joined: Apr 2003
Posts: 1
Worked for me. Change your socket open to:

sockopen ebaysock cgi3.ebay.com 80

Change your get statement to:

sockwrite -n $sockname GET /aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.0 $+ $crlf $+ $crlf

Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
cool, it works! smile Thank you. I have to read more about sockets & co....


Mathias

#19039 14/04/03 04:19 PM
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
I have the next problem...:

When I open the website http://cgi3.ebay.de/aw-cgi/eBayISAPI.dll?TimeShow in my browser (IE), there is a german site with the eBay time. When I use the socket in mIRC with:

sockopen ebaysock cgi3.ebay.de 80 or
sockopen ebaysock cgi3.ebay.com 80

and

sockwrite -n $sockname GET /aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.0 $+ $crlf $+ $crlf


I can only see the american site of the eBay Time. What is wrong?? When I use cgi3.ebay.de, there is the U. S.-Site, too?!

Mathias

#19040 14/04/03 05:15 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
As I told you in my post, READ THE RFCs. It clearly states that if you want to use a specific host, you must send a Host: header (I even said this in my previous post).

#19041 14/04/03 05:46 PM
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
I do not really understand it. Where is this in the RFC's? Must I send the host name to the website??

/sockwrite ebaysock host cgi3.ebay.de

???

Mathias

#19042 14/04/03 07:11 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
If you are attempting to code a client for a particular protocol, then you must know the protocol which is to be used. You clearly do not. Reading the ENTIRE RFC will give you a decent idea of how the protocol works.

#19043 14/04/03 10:47 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Aww code, go easy on the beginners.. >:)

Anyways, yes you need to realize that the server's information that is sent back to you is based on things called headers. These are the things that tell the website what browser you're running, your ip, and also *language*.. If you want the german site, I would suggest adding the line:

/sockwrite -n $sockname Accept-Language: en-us

*Note: That is for english, I'm not sure as to what en-us is for German, but i'll leave that to you.

Anways, hope that clearifies, and takes (some) stress off poor code's back. grin


-KingTomato
#19044 15/04/03 03:17 AM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
It doesn't have anything to do with the Accept-Language header, it has to do with the lack of a Host header. All he is doing is connecting to an IP, ebay doesn't know what URL you actually meant, you have to send it a Host header to tell it what host (cgi3.ebay.de) you are talking about.

#19045 15/04/03 10:24 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
/sockwrite -n $sockname Host: cgi3.ebay.de

or w/e the host is, I've no idea, but that's the syntax.

#19046 15/04/03 11:30 AM
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
I'm sorry, but there is no text about it. I only find this here:

10.14 Server

The Server response-header field contains information about the
software used by the origin server to handle the request. The field
can contain multiple product tokens (Section 3.7) and comments
identifying the server and any significant subproducts. By
convention, the product tokens are listed in order of their
significance for identifying the application.

Server = "Server" ":" 1*( product | comment )

Example:

Server: CERN/3.0 libwww/2.17


and this here:

The most common form of Request-URI is that used to identify a
resource on an origin server or gateway. In this case, only the
absolute path of the URI is transmitted (see Section 3.2.1,
abs_path). For example, a client wishing to retrieve the resource
above directly from the origin server would create a TCP connection
to port 80 of the host "www.w3.org" and send the line:

GET /pub/WWW/TheProject.html HTTP/1.0

followed by the remainder of the Full-Request. Note that the absolute
path cannot be empty; if none is present in the original URI, it must
be given as "/" (the server root).



What do you mean? Please give me an example for it.

Mathias

#19047 15/04/03 11:33 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138

#19048 15/04/03 02:17 PM
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
ok, i tried it, but it doesn't work. my first idea was this here:

sockwrite -n $sockname GET /aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.1 $+ $crlf $+ $crlf
sockwrite -n $sockname Host: cgi3.ebay.de

and then I tried it so:

sockwrite -n $sockname GET /aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.1 $+ $crlf $+ $crlf Host: www.ebay.de


What is wrong here?

Greets, Mathias

#19049 15/04/03 02:33 PM
Joined: Feb 2003
Posts: 47
G
Ameglian cow
Offline
Ameglian cow
G
Joined: Feb 2003
Posts: 47
You need to send each line of data to the server with a $crlf at the end. You are automatically doing this by sockwrite -n
-n adds a newline if there isn't one already. The HTTP header you are sending must be ended by a $crlf.

Code:
sockwrite -n $sockname GET /aw-cgi/eBayISAPI.dll?TimeShow HTTP/1.1
sockwrite -n $sockname Host: cgi3.ebay.de
sockwrite $sockname $crlf


that should work then

#19050 15/04/03 06:50 PM
Joined: Mar 2003
Posts: 86
N
NRJ Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 86
yeah, it works! smile Thank you, very much smile)

Greets, Mathias


Link Copied to Clipboard