mIRC Home    About    Download    Register    News    Help

Print Thread
#102369 08/11/04 03:31 AM
Joined: Oct 2004
Posts: 8,061
R
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
HTTP Headers are a royal pain! smile

Anyhow, I'm having problems with weatherunderground.com site. Below is the server http header that I receive when I try to GET a zipcode's weather:

HTTP/1.1 302
Date: Mon, 08 Nov 2004 03:19:37 GMT
Server: Apache/1.3.28 (Unix) PHP/4.3.3
Cache-control: no-cache, no-cache="Set-Cookie", private
Expires: Fri, 01 Jan 1999 00:00:00 GMT
Pragma: no-cache
Location: http://www.weatherunderground.com/cgi-bin/findweather/getForecast?query=01020
Connection: close
Content-Type: text/html
Redirect page<br><br>

Obviously, it's closing the connection on a redirect page that I don't see when I simply browse the site in my browser. It also mentions cookies. Does anyone know how I can make the connection work when it's apparently using cookies for whatever purpose?

Here is my sockopen info:

on *:sockopen:weather: {
sockwrite -n $sockname get /cgi-bin/findweather/getForecast?query= $+ %zipcode HTTP/1.0
sockwrite -n $sockname Referer: weatherunderground.com
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
sockwrite -n $sockname Host: weatherunderground.com $+ $crlf $+ $crlf
sockwrite -n $sockname Accept-Language: en-us
sockwrite -n $sockname Accept-Encoding: gzip, deflate
sockwrite -n $sockname Accept: */*
}

#102370 08/11/04 11:51 AM
Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
The cookie junk is non-sense ignore it.

The one reason your script isn't working is because, very simply;

Host: weatherunderground.com isn't correct, you want Host: www.weatherunderground.com

In most cases, it is true that both domain.com and www.domain.com are the exact same, however in others, they are completely differnet, and in this case, one redirects to the other, if you load IE, or a browser, type, weatherunderground.com in the bar and click 'Go' you will see it change to www.weatherunderground.com, thus its redirected you just dont see it. smile

Furthermore, it makes no difference but the only lines you need are;


sockwrite -n $sockname get /cgi-bin/findweather/getForecast?query= $+ %zipcode HTTP/1.0
sockwrite -n $sockname Host: www.weatherunderground.com
sockwrite -n $sockname

Hope this helps.

Eamonn.

#102371 08/11/04 11:57 AM
Joined: Oct 2004
Posts: 8,061
R
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Cool! Thanks! cool


Link Copied to Clipboard