Kjra Posted October 15, 2010 Posted October 15, 2010 Hello, please help me to know where i was wrong in this code, i want count how many line i got in 1 page and result it to number, but seem i was wrong some where, please help me correct it. #include <IE.au3> #include <String.au3> dim $stringyouwant[50] $url = "http://dnstrouble.com/index.php?content=spamcheck&domain=98.245.137.65" $IE=_IECreate($url) _IELoadWait($IE) $src=_IEDocReadHTML($IE) $stringyouwant[0] = "Listed in Black List" $c = 0 $beforetext = '<span class="redb">' $aftertext = '</span>' While($stringyouwant[$c] <> "") $c = $c + 1 $stringyouwant[$c]=_StringBetween($src,$beforetext,$aftertext) $wantToDelete = $beforetext & $stringyouwant[$c] & $aftertext $src=StringReplace($src,$wantToDelete,'') Wend $total = $c for $i = 1 to $total MsgBox(0, "Test", "result #"& $i & ': ' & $stringyouwant[$i]) Next
Affe Posted October 15, 2010 Posted October 15, 2010 (edited) First, welcome to the forums! Second, I went ahead and did things a little differently for you. This way you don't have to load IE and everything. I've thrown in a few _ArrayDisplay's to give you an idea of what is going on throughout the script. Hope this helps! expandcollapse popup#include <Array.au3> $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;GET request $oHTTP.Open("GET", "http://dnstrouble.com/index.php?content=spamcheck&domain=98.245.137.65", False) ;Add user agent User-Agent= $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 AskTbMYC/3.8.0.12304 Firefox/3.6.6 ( .NET CLR 3.5.30729; .NET4.0E)") ;Add Content-Type $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;Add Keep-Alive $oHTTP.SetRequestHeader("Keep-Alive", "115") ;Add Connection $oHTTP.SetRequestHeader("Connection", "keep-alive") ;Cache-Control $oHTTP.SetRequestHeader("Cache-Control", "max-age=0") ;Send GET request $oHTTP.Send("") $src = $oHTTP.ResponseText ConsoleWrite($src & @CRLF) $beforetext = '<span class="redb">' $String = StringSplit($src, "<tr>", 1) _ArrayDelete($string, 0) _ArrayDelete($string, 0) $x = UBound($String) _ArrayDelete($string, $x - 1) $x = UBound($String) _ArrayDelete($string, $x - 1) _ArrayDisplay($string) $x = UBound($String) Dim $Split[$x][3] For $x = 0 To UBound($String) - 1 $temp = $String[$x] $temp = StringSplit($temp, "<td>", 1) $Split[$x][0] = StringReplace($temp[2], "</td>", "") $Split[$x][1] = StringReplace($temp[3], "</td>", "") $Split[$x][2] = StringReplace($temp[4], "</td>", "") Next _ArrayDisplay($Split) $finds = _ArrayFindAll($Split, $beforetext, 0, 0, 0, 1, 2) For $x = 0 To UBound($finds) - 1 $num = $finds[$x] $finds[$x] = $Split[$num][0] Next _ArrayDisplay($finds) Edited October 15, 2010 by Affe [center][/center]
Kjra Posted October 15, 2010 Author Posted October 15, 2010 (edited) Thanks your great help it's work as i think , but as a newbie to learn, can u explain to me why u was used so much line: _ArrayDelete($string, 0) _ArrayDelete($string, 0) $x = UBound($String) _ArrayDelete($string, $x - 1) $x = UBound($String) _ArrayDelete($string, $x - 1) Edited October 15, 2010 by Kjra
Affe Posted October 18, 2010 Posted October 18, 2010 Thanks your great help it's work as i think , but as a newbie to learn, can u explain to me why u was used so much line: _ArrayDelete($string, 0) _ArrayDelete($string, 0) $x = UBound($String) _ArrayDelete($string, $x - 1) $x = UBound($String) _ArrayDelete($string, $x - 1) I put those in there to trim out the surrounding HTML. If you like, you can do an _ArrayDisplay before I do the deletes to see the information I trim out. [center][/center]
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