script to display html problem - only header! - 12/01/15 04:20 PM
Hi all!
I've spent pretty much the last day solidly learning how to script in mirc (oh, and I had an exam xD). It's gone well but I've hit one final stumbling block...
I want to type !elo <nickname> in my channel, and have my bot respond with the elo of <nickname>. The information is handily stored on this website (e.g. nickname = earth_quake):
http://www.qlranks.com/api.aspx?nick=earth_quake
I have managed to make my bot print out the header of the webpage...but nothing else. When I try other websites I can print the entire html source of the webpage. What is going wrong? Any help would be much appreciated
2nd question: How can I create a global variable defined in "on $*:text:!elo*:#: {" that contains the <nickname> specified, that is then accessible in "on *:SOCKOPEN:QLR: {" ? i.e. GET /api.aspx?nick=<nickname>
Thank youuuuuu <3
I've spent pretty much the last day solidly learning how to script in mirc (oh, and I had an exam xD). It's gone well but I've hit one final stumbling block...
I want to type !elo <nickname> in my channel, and have my bot respond with the elo of <nickname>. The information is handily stored on this website (e.g. nickname = earth_quake):
http://www.qlranks.com/api.aspx?nick=earth_quake
I have managed to make my bot print out the header of the webpage...but nothing else. When I try other websites I can print the entire html source of the webpage. What is going wrong? Any help would be much appreciated
2nd question: How can I create a global variable defined in "on $*:text:!elo*:#: {" that contains the <nickname> specified, that is then accessible in "on *:SOCKOPEN:QLR: {" ? i.e. GET /api.aspx?nick=<nickname>
Code:
on $*:text:!elo*:#: { msg $chan Getting elo for $$2 ... if ($sock(QLR)) { .sockclose QLR msg #prdxclan Socket already open! Closed socket, trying again... } sockopen QLR www.qlranks.com 80 } on *:SOCKOPEN:QLR: { msg #prdxclan Opened socket... ; $sockname stands for the name of the socket - QLR sockwrite -n $sockname GET /api.aspx?nick=earth_quake HTTP/1.1 sockwrite -n $sockname Accept: */* sockwrite -n $sockname Accept-Language: en-us sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; DigExt) sockwrite -n $sockname Host: www.qlranks.com sockwrite -n $sockname sockwrite $sockname $crlf ; sent data to QLR socket requesting the api info for earth_quake } on *:SOCKREAD:QLR: { if ($sockerr > 0) return :nextread sockread %temp ; read the data coming from the socket if ($sockbr == 0) { sockclose %sockname } ; if i've read all the data, stop if (%temp) { msg #prdxclan %temp } ; if there was stuff received from the socket, then echo it goto nextread } on *:SOCKCLOSE:QLR: { msg #prdxclan Closed socket. }
Thank youuuuuu <3