Shonnie Posted November 15, 2007 Posted November 15, 2007 What I would like to do, is parse the html inside the body tag of a website, split it into an array, then trim off some extra and convert it to a number. The number I want is always in the same place on the line, but not always in the same place in the array.What I tried to do (Excuse the sloppy coding :blush:) was... Read the html, split it, search the array for a word that only appears once on the site which is right beside the number, then use that line number as a variable thats further parsed to remove some lines from the left, then the right, and finally converted to a number.This all works if I reset $MHP2 = $MHP[$MHP6] to $MHP2 = $MHP[36] or whichever array line "mon" is on, but doesnt work if I want it to find itself.$sHTML = _IEBodyReadHTML($oIE) $MHP = StringSplit($sHTML, @CR) $MHP7 = _ArraySearch($MHP, "mon", 0, 0, 0, True) $MHP6 = Number($MHP7) $MHP2 = $MHP[$MHP6] $MHP3 = StringTrimLeft($MHP2, 42) $MHP4 = StringTrimRight($MHP3, 21) $MHP5 = Number($MHP4)$MHP2 = $MHP[$MHP6]"Array variable subscript badly formatted"Is there any way to do what I'm aiming for? Or perhaps other function names I could look at?Thanks for halp
Valuater Posted November 15, 2007 Posted November 15, 2007 Maybe you could try this approach expandcollapse popup; demonstration to find chracters that change between to standard points ; or just find a string #include <IE.au3> #include <String.au3> #Region --- IE-Builder generated code Start --- $oIE = _IECreate("about:blank", 0, 0) ;------------- User input -------------- _IENavigate ($oIE, "http://www.autoitscript.com/") ; web address $Find = "Welcome to the " ; my info shows after this line... or just find this line $Before = "- the home " ; my info shows before this line... or set as "" ; ------------ End User input ------------- Sleep(1000) $body = _IEBodyReadHTML($oIE) $sloc = @TempDir & "\test.txt" FileDelete($sloc) FileWrite($sloc, $body) $sfile = FileOpen($sloc, 0) $num = 0 While 2 $num = $num + 1 $sline = FileReadLine($sfile, $num) If @error Then MsgBox(262208, "Fail", "The string was NOT found ") FileClose($sfile) Exit EndIf If StringInStr($sline, $Find) Then MsgBox(64, "Success", "The string " & $Find & " was found " & @CRLF & " on line # " & $num, 5) If $Before = "" Then ExitLoop $Found = _StringBetween($sline, $Find, $Before) MsgBox(64, "Found", "The string is " & $Found[0] & " ", 5) ExitLoop EndIf WEnd #EndRegion --- IE-Builder generated code End --- 8)
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