gosu Posted January 27, 2005 Posted January 27, 2005 Hi guys,I need help parsing this link. I want to look for an ip and get ALL the info: name, info, map, players version.How would I do this? [quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]
nOne Posted January 27, 2005 Posted January 27, 2005 (edited) Hi guys,I need help parsing this link. I want to look for an ip and get ALL the info: name, info, map, players version.How would I do this?<{POST_SNAPBACK}>here is the code to get it if you start it you will see 7 msg boxes with always the first 10 entrys of a categoriehf expandcollapse popup$textfile = "soldat.txt" InetGet("http://lobby.soldat.pl:13073/index.php", $textfile, 1) $file = FileOpen($textfile, 0) $lines = 300 Dim $serverarray[$lines][8] $num = 1 $pass = 0 for $count = 1 to $lines $line = FileReadLine($file, $count+24) If ( StringLeft($line, 38) == ' <td width="24%"><a href="soldat://' ) Then $currentline = StringTrimLeft($line, 38) $ippos = StringInStr( $currentline ,'/"><font color="#79E958">') $ip = StringLeft($currentline, $ippos-1) $server = StringTrimLeft($currentline, $ippos+24) $server = StringTrimRight($server,16) If ( StringInStr($server, '<i>') ) Then $server = StringTrimRight(StringTrimLeft($server, 6),8) ElseIf ( StringInStr($server, '<b>') ) Then $server = StringTrimRight(StringTrimLeft($server, 3),4) EndIf $serverarray[$num][1] = $ip $serverarray[$num][2] = $server ElseIf ( StringLeft($line, 20) == ' <td width="37%">' ) Then $info = StringTrimRight(StringTrimLeft($line, 20), 5) $serverarray[$num][3] = $info ElseIf ( (StringLeft($line, 19) == ' <td width="8%">' ) AND ($pass == 0)) Then $mode = StringTrimRight(StringTrimLeft($line, 19), 5) $serverarray[$num][4] = $mode ElseIf ( StringLeft($line, 20) == ' <td width="14%">' ) Then $map = StringTrimRight(StringTrimLeft($line, 20), 5) $serverarray[$num][5] = $map ElseIf ( StringLeft($line, 20) == ' <td width="12%">' ) Then $players = StringTrimLeft($line, 20) $serverarray[$num][6] = $players ElseIf ( StringLeft($line, 5) == '</td>' ) Then $pass = 1 ElseIf ( (StringLeft($line, 19) == ' <td width="8%">' ) AND ($pass == 1)) Then $version = StringTrimRight(StringTrimLeft($line, 19), 5) $serverarray[$num][7] = $version $pass = 0 $num = $num+1 EndIf next ; $serverarray[$count][1] = IP ; $serverarray[$count][2] = Server Name ; $serverarray[$count][3] = Info ; $serverarray[$count][4] = Mode ; $serverarray[$count][5] = Map ; $serverarray[$count][6] = Players ; $serverarray[$count][7] = Version for $counta = 1 to 7 $text = "" for $count = 1 to 10 $msg = $serverarray[$count][$counta] & @CRLF & @CRLF $text = $text & $msg next MsgBox(0, $counta , $text) next FileClose($file) FileDelete($textfile)edit: server names are now displayed Edited January 27, 2005 by nOne
gosu Posted January 27, 2005 Author Posted January 27, 2005 here is the code to get it if you start it you will see 7 msg boxes with always the first 10 entrys of a categoriehf Thank you so much. I will of course mention you in the tool when it´s done. If there is anything more I can do for you, just PM me. [quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]
Blue_Drache Posted January 27, 2005 Posted January 27, 2005 here is the code to get it if you start it you will see 7 msg boxes with always the first 10 entrys of a categoriehf $textfile = "soldat.txt" InetGet("http://lobby.soldat.pl:13073/index.php", $textfile, 1) $file = FileOpen($textfile, 0) $lines = 300 Dim $serverarray[$lines][8]Why is $lines a static? Why not loop it? That way you are not limited by a specific file size.$textfile = "soldat.txt" InetGet("http://lobby.soldat.pl:13073/index.php", $textfile, 1) $file = FileOpen($textfile, 0) ;;; modification begins here If @error = -1 then exit $lines = 0 While 1 FileReadLine($textfile) If @error then Exitloop $lines = $lines + 1 Sleep(10) WEnd ;;; modification ends here Dim $serverarray[$lines][8]Just a thought Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
nOne Posted January 27, 2005 Posted January 27, 2005 because the file has a lot more lines then servers .. no need to make a dim $array[2000] if a dim $array[300] is enough but there are still posibilities to make the array lager each loop with redim, but i was too lazy for this or is there a way to strip empty array plazes ? if not would be a thought for an udf
Blue_Drache Posted January 27, 2005 Posted January 27, 2005 (edited) because the file has a lot more lines then servers ..no need to make adim $array[2000]if adim $array[300]is enoughbut there are still posibilities to make the arraylager each loop with redim, but i was too lazy for this or is there a way to strip empty array plazes ?if not would be a thought for an udf <{POST_SNAPBACK}>Meh, I'd just read the entire file in, find the common point to start the table array, read until the table ends (probably a standard marker for that anyway) and toss the rest of the data out the winodw.... or keep it for later processing if necessary. In many of my screen scraping functions, I grab a whole lot of information that may be useless for the task I'm performing, but the information is there if needed.Besides, you're only limited to Dim $array[2^24] so 2k is tiny compared to 16,7777,216 elements. Edited January 27, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now