mIRC Home    About    Download    Register    News    Help

Print Thread
Sockets: getting extra data from page with no HTML #225335 30/08/10 08:37 PM
Joined: May 2005
Posts: 449
bwr30060 Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
It's been awhile since I've done any scripting. I'm trying to use sockets to connect to a page that only has an IP address on it and then connect to the IRC server with that address. The problem is that the socket is returning more than the IP address, even though there is no HTML on the page. Here is what I'm getting:

Quote:
HTTP/1.1 200 OK
Date: Mon, 30 Aug 2010 20:30:19 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sun, 22 Aug 2010 19:05:49 GMT
ETag: "38c8182-e-48e6e384d9d40"
Accept-Ranges: bytes
Content-Length: 14
Content-Type: text/plain


I think the fact that I'm not getting more is a looping problem in the script.

Re: Sockets: getting extra data from page with no HTML [Re: bwr30060] #225336 30/08/10 09:12 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You can use an IF to check if the line is the right line so you can use just that IP. You first have to look at your script and get it to read the entire page, however.


Invision Support
#Invision on irc.irchighway.net
Re: Sockets: getting extra data from page with no HTML [Re: bwr30060] #225452 02/09/10 06:22 PM
Joined: Aug 2010
Posts: 11
G
GreyStar Offline
Pikka bird
Offline
Pikka bird
G
Joined: Aug 2010
Posts: 11

What version mirc are you running? I was messing with sockets and the code wouldnt bring in the data on 6.2, but I got 7.1 and it works fine.


Re: Sockets: getting extra data from page with no HTML [Re: bwr30060] #225458 02/09/10 09:03 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline
Fjord artisan
Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Originally Posted By: bwr30060
It's been awhile since I've done any scripting. I'm trying to use sockets to connect to a page that only has an IP address on it and then connect to the IRC server with that address. The problem is that the socket is returning more than the IP address, even though there is no HTML on the page. Here is what I'm getting:

Quote:
HTTP/1.1 200 OK
Date: Mon, 30 Aug 2010 20:30:19 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sun, 22 Aug 2010 19:05:49 GMT
ETag: "38c8182-e-48e6e384d9d40"
Accept-Ranges: bytes
Content-Length: 14
Content-Type: text/plain


I think the fact that I'm not getting more is a looping problem in the script.


These are the page headers sent to the socket by the server. You need to parse the data accordingly to make sure you get the data you want from the page.


Newbie
Re: Sockets: getting extra data from page with no HTML [Re: bwr30060] #225469 03/09/10 01:49 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You should request HTTP/1.0 data instead of HTTP/1.1 .

The web server will return some unknown number of headers, like the ones you listed. It will then send a blank line. Then the content of the webpage will begin to send. You can make your script ignore everything it sees before that first blank line, and read everything after the blank line.

Put this right before your /sockopen command:

set %ignore 1


Then in your sockread event, add this check at the top:

var %read
sockread %read
if (%read == $null) { set %ignore 0 | return }
if (%ignore) return

;Rest of your code here. Data is in %read


If you plan on opening this socket more than once at a time, you will need to make the %ignore variable dynamic based on the socket name.

-genius_at_work