Jump to content

Only read certain lines with _IEBodyReadHTML


Recommended Posts

I'm trying to process data from a web page, I know how to use _IEBodyReadText and _IEBodyReadHTML, I want to read the HTML but only lines that begin with <td class="formContent">

So what I want to do is read the HTML, and any line with <td class="formContent"> will be set to an array for later usage. The problem is, is it possible to do that? I know you could write the html to a text file then read the text file by line, but I would prefer to not use a text file, just have the program handle all of it internally.

Link to comment
Share on other sites

I'm trying to process data from a web page, I know how to use _IEBodyReadText and _IEBodyReadHTML, I want to read the HTML but only lines that begin with <td class="formContent">

So what I want to do is read the HTML, and any line with <td class="formContent"> will be set to an array for later usage. The problem is, is it possible to do that? I know you could write the html to a text file then read the text file by line, but I would prefer to not use a text file, just have the program handle all of it internally.

_IETagNameGetCollection($oIE, "td") to get all the "td" tags, then you'll have to make one loop through the collect to find the class you are looking for.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hmmmmm, here's where I'm sitting at trying to just get it to show all the td classes:

$sText = _IETagNameGetCollection($oIE, "td")
    For $sTxt In $sText
            MsgBox(0, "", "Class Name: " & $sTxt.class)
    Next

But its crashing as soon as I get there. I am running Vista so I have to require admin which for some reason stops the console log and doesnt show anything other than exiting as soon as I give it permission (program still runs but I dont see any errors appear in the log when it crashes).

Link to comment
Share on other sites

Hmmmmm, here's where I'm sitting at trying to just get it to show all the td classes:

$sText = _IETagNameGetCollection($oIE, "td")
    For $sTxt In $sText
            MsgBox(0, "", "Class Name: " & $sTxt.class)
    Next

But its crashing as soon as I get there. I am running Vista so I have to require admin which for some reason stops the console log and doesnt show anything other than exiting as soon as I give it permission (program still runs but I dont see any errors appear in the log when it crashes).

Just replace .class with .outerhtml.

Ohhh didn't realize you could do it Psalty's way...

@PsaltyDS... but your a penguin surely you must be more afraid of vista then a little water... hehehe

Edited by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Hmmmmm, here's where I'm sitting at trying to just get it to show all the td classes:

$sText = _IETagNameGetCollection($oIE, "td")
    For $sTxt In $sText
            MsgBox(0, "", "Class Name: " & $sTxt.class)
    Next

But its crashing as soon as I get there. I am running Vista so I have to require admin which for some reason stops the console log and doesnt show anything other than exiting as soon as I give it permission (program still runs but I dont see any errors appear in the log when it crashes).

Two things I'm glad to have never experienced: Waterboarding and Windows Vista

On the other problem, try .ClassName instead of .class:

$colTD = _IETagNameGetCollection($oIE, "td")
$iTD = @extended
Msgbox(64, "Table Data", "There are " & $iTD & " TD tags in the collection.")
For $oTD In $colTD
    MsgBox(0, "", "Class Name: " & $oTD.ClassName)
Next

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Two things I'm glad to have never experienced: Waterboarding and Windows Vista

Vista isnt bad once you get use to the changes. Just like XP it sucked when it first came out (from what I heard) but its much more stable now. Performance wise it doesnt seem any slower than XP was.

$sText = _IETagNameGetCollection($oIE, "td")
    For $sTxt In $sText
        If ($sTxt.ClassName == "formContent") Then
            FileWriteLine($file, $sTxt.innertext)
        ;MsgBox(0, "", "Class Name: " & $sTxt.outerHTML)
        EndIf
    Next

Seemed to pull the correct text I was looking for (wrote to a text file for testing purposes).

Now, next part, how can I write the text it pulls to an array? I know how arrays work and what not but I am not fully clear on how $sTxt.innertext works. It seems similar to an array (each pass through the loop gives different results) but if I try to set $array = $sTxt.innertext (i starts at 0 and increments each time the class formContent is found), it just crashes.

Link to comment
Share on other sites

$colTD = _IETagNameGetCollection($oIE, "td")
$iTD = @extended
Global $avTD[$iTD + 1]; max array size
$iTD = 0
For $oTD In $colTD
    If $oTD.ClassName = "formContent" Then
        $iTD += 1
        $avTD[$iTD] = $oTD.InnerText
    EndIf
Next
$avTD[0] = $iTD; [0] = count
ReDim $avTD[$iTD + 1]; resize to used elements only
_ArrayDisplay($avTD, "Matching TD Tags")

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hmmmm......its crashing on the _ArrayDisplay line, if I call a message box to show the $avTD[$iTD] in every iteration of the loop it shows what it should, but the _ArrayDisplay() is crashing out (commenting it out stops it from crashing). Really wish the console would work with #requireadmin so I could see the errors that are popping up......

Link to comment
Share on other sites

Hmmmm......its crashing on the _ArrayDisplay line, if I call a message box to show the $avTD[$iTD] in every iteration of the loop it shows what it should, but the _ArrayDisplay() is crashing out (commenting it out stops it from crashing). Really wish the console would work with #requireadmin so I could see the errors that are popping up......

Did you #include <Array.au3> so you would have _ArrayDisplay() available...?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...