mIRC Home    About    Download    Register    News    Help

Print Thread
#28477 06/06/03 06:52 PM
Joined: May 2003
Posts: 10
V
voice Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: May 2003
Posts: 10
Im trying to make a weather script, but for some reason when it gets to the GET command, the socket has already been closed. How can i fix this?

#28478 06/06/03 06:53 PM
Joined: May 2003
Posts: 10
V
voice Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: May 2003
Posts: 10
opps sorry, forgot the code:

on *:text:-weather*:#:{
notice $nick Attempting to connect to weather server.
set %whowanted $nick
set %zipcode $2
sockopen weather http://www.weather.com 80
}

on *:sockopen:weather:{
notice %whowanted Connection to weather server established, now retriving weather data for US zip code: %zipcode
sockwrite -n $sockname GET /weather/local/ $+ %zipcode $+ ?lswe= $+ %zipcode $+ &lwsa=WeatherLocalUndeclared sockwrite -n $sockname HTTP/1.0 HTTP/1.0
sockwrite -n $sockname $crlf
echo -s system connected to weather.com!
}

on *:sockread:weather:{
if ($sockerr > 0) return
:nextread
sockread %weathertemp
if ($sockbr == 0) return
if (%weathertemp == $null) %weathertemp = -
notice %whowanted %weathertemp
goto nextread
}

#28479 06/06/03 07:47 PM
Joined: Dec 2002
Posts: 169
J
Vogon poet
Offline
Vogon poet
J
Joined: Dec 2002
Posts: 169
Sockopen opens up a connection to a host, not an url

sockopen weather www.weather.com 80

sockwrite -n $sockname GET /weather/local/ $+ %zipcode $+ ?lswe= $+ %zipcode $+ &lwsa=WeatherLocalUndeclared HTTP/1.1

Next Part:
The actual page consists of much much more than the temperature. Open it up with a web browser and View Source. In your sockread you are going to need to pick the temperature out of all that data.


Link Copied to Clipboard