Sign in to follow this  
Followers 0
Sorak99

IE.au3 Help

12 posts in this topic

Hello,

I am trying to make a program that goes to http://www.saintsreport.com/ then only clicks on the full story links from today.

I found a script a while back that helps decipher certain fields:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <IE.au3>

; Set a COM Error handler -- only one can be active at a time (see helpfile)
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

; Create a browser window, navigate and click to the AutoIt Forum Search page
$oIE = _IECreate ()
_IENavigate ($oIE, "http://www.saintsreport.com/")
;_IEClickLinkByText ($oIE, "forum")
;_IEClickLinkByText ($oIE, "Search")

; Show information for each HTML elemetn on a page
$o_all = _IETagNameAllGetCollection ($oIE)
$sHTM = _IECollectionTable($o_all, "Characteristics of all HTML Elements on page")
$oIE1 = _IECreate ()
_IEBodyWriteHTML ($oIE1, $sHTM)

; Show information for each A (anchor) tag
$o_all = _IETagNameGetCollection ($oIE, "a") 
$sHTM = _IECollectionTable($o_all, "Characteristics of all 'a' Links")
$oIE2 = _IECreate ()
_IEBodyWriteHTML ($oIE2, $sHTM)

; Show attributes for each IMG tag
$o_all = _IETagNameGetCollection ($oIE, "img")
$sHTM = _IECollectionTable($o_all, "Characteristics of all 'img' Links")
$oIE3 = _IECreate ()
_IEBodyWriteHTML ($oIE3, $sHTM)

; Show information on each form and its elements
$o_all = _IEFormGetCollection ($oIE)
$oIE4 = _IECreate ()
$icnt = 0
For $form in $o_all
    $sBody = _IEBodyReadHTML($oIE4)
    If $icnt = 0 Then $sBody = ""
    $sHTM = _IECollectionTable($form, "Elements for form " & $icnt)
    _IEBodyWriteHTML ($oIE4, $sBody & $sHTM)
    $icnt = $icnt + 1
Next

Exit

Func _IECollectionTable($o_collection, $s_title = "HTML Element Collection")
    Dim $adata[5]
    Dim $i = 0
    Dim $sHTML = ""
    
    $sHTML = $sHTML & "<h2>" & $s_title & "</h2>" & @CR
    $sHTML = $sHTML & "<table border=1 cellpadding=3>" & @CR
    $sHTML = $sHTML & "<tr bgcolor=navy><td><font color=""white""><b>Object Type</b></font>"
    $sHTML = $sHTML & "<td><font color=""white""><b>Object Count</b></font>"
    $sHTML = $sHTML & "<tr><td>" & ObjName ($o_collection) & "</td><td>" & $o_collection.length & "</td></tr></table>" & @CR & @CR
  ;
    $sHTML = $sHTML & "<h3>Element Characteristics</h3>" & @CR
    $sHTML = $sHTML & "<table border=1 cellpadding=3>" & @CR
    $sHTML = $sHTML & "<tr bgcolor=navy><td><font color=""white""><b>Index</b></font>"
    $sHTML = $sHTML & "</td><td><font color=""white""><b>Tag</b></font>"
    $sHTML = $sHTML & "</td><td><font color=""white""><b>Name</b></font>"
    $sHTML = $sHTML & "</td><td><font color=""white""><b>Id</b></font>"
    $sHTML = $sHTML & "</td><td><font color=""white""><b>Extra Information</b></font>"
    $sHTML = $sHTML & "</td><td><font color=""white""><b>Object Type</b></font>"
    $sHTML = $sHTML & "</td></tr>" & @CR
    
    For $a In $o_collection
      ;
        SetError(0)
        $tmp = $a.tagname
        If @error = 1 Then $tmp = " "
        If $tmp = "0" Then $tmp = " "
        $adata[0] = $tmp
      ;
        SetError(0)
        $tmp = $a.name
        If @error = 1 Then $tmp = " "
        If $tmp = "0" Then $tmp = " "
        $adata[1] = $tmp
      ;
        SetError(0)
        $tmp = $a.id
        If @error = 1 Then $tmp = " "
        If $tmp = "0" Then $tmp = " "
        $adata[2] = $tmp
      ;
        Select
            Case $a.tagname = "a"
                SetError(0)
                $tmp = "Link Text: " & $a.innerText & "<br>href: " & $a.href
                If @error = 1 Then $tmp = " "
                If $tmp = "0" Then $tmp = " "
                $adata[3] = $tmp
            Case $a.tagname = "img"
                SetError(0)
                $tmp = "Img SRC: " & $a.src & "<br>alt Text: " & $a.alt
                If @error = 1 Then $tmp = " "
                If $tmp = "0" Then $tmp = " "
                $adata[3] = $tmp
            Case $a.tagname = "input"
                SetError(0)
                $tmp = "Form Input Type: " & $a.type & "<br>Value: " & $a.value
                If @error = 1 Then $tmp = " "
                If $tmp = "0" Then $tmp = " "
                $adata[3] = $tmp
            Case $a.tagname = "option"
                SetError(0)
                $tmp = "Option index: " & $a.index & "<br>Value: " & $a.value & "<br>Selected: " & $a.selected
                If @error = 1 Then $tmp = " "
                If $tmp = "0" Then $tmp = " "
                $adata[3] = $tmp
            Case Else
                $adata[3] = " "
        EndSelect
      ;
        SetError(0)
        $tmp = ObjName ($a)
        If @error = 1 Then $tmp = " "
        If $tmp = "0" Then $tmp = " "
        $adata[4] = $tmp
      ;
        $sHTML = $sHTML & "<tr><td class=tr-main>" & $i
        $sHTML = $sHTML & "</td><td class=tr-main>" & $adata[0]
        $sHTML = $sHTML & "</td><td class=tr-main>" & $adata[1]
        $sHTML = $sHTML & "</td><td class=tr-main>" & $adata[2]
        $sHTML = $sHTML & "</td><td class=tr-main>" & $adata[3]
        $sHTML = $sHTML & "</td><td class=tr-main>" & $adata[4]
        $sHTML = $sHTML & "</td></tr>" & @CR
        $i = $i + 1
    Next
    $sHTML = $sHTML & "</table>" & @CR
    Return $sHTML
EndFunc ;==>_IECollectionTable


Func MyErrFunc()
; Set @ERROR to 1 and return control to the program following the trapped error
    SetError(1)
EndFunc ;==>MyErrFunc

but my progress is slow in most cases and in this instance I'm stuck on how to proceed.

George

Share this post


Link to post
Share on other sites



This should either get you started, or confuse you really bad. :D

#include <IE.au3>

_IEErrorHandlerRegister ()

; Create a browser window and navigate to a webpage
$oIE = _IECreate ("http://www.saintsreport.com", 1)

; Get a collection object of all Links
$oLinks = _IELinkGetCollection ($oIE)

; Loop through all Links
For $oLink In $oLinks
    $sLinkText = $oLink.outerText & ""
    If StringInStr($sLinkText, "Full Story -") Then
        $oParent = $oLink.parentElement
        For $i = 1 To 6
            $oParent = $oParent.parentElement
        Next
        $oParent = $oParent.previousSibling
        $sParentText = $oParent.innerText
        If StringInStr($sParentText, "Today @") Then
            $sLinkPath = $oLink.href
            _IECreate ($sLinkPath, 0, 1, 0)
        EndIf
    EndIf
Next

Share this post


Link to post
Share on other sites

very nice big_daddy!

I just thought he took some script, posted it and was asking alot

so i didn't even try

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

very nice big_daddy!

I just thought he took some script, posted it and was asking alot

so i didn't even try

8)

Thanks!

It was a little harder than I initially thought, but I finally figured it out.

Share this post


Link to post
Share on other sites

This should either get you started, or confuse you really bad.

It does both, but i will study it for a few days.

very nice big_daddy!

I just thought he took some script, posted it and was asking alot

so i didn't even try

8)

The script i put up is a tool i use to make anything with IE.au3, found it in a much earlier post. Other than opening up the site, i had no idea how to start. So i wanted to give anyone that wanted to help me something rather than nothing. I figure most people find it unncessary and i believe that this code doesnt need it at all. (i suck bad with IE.au3 and ExcelCom.au3)

I feel bad sometimes asking because its just like when your playing a mmorpg and the low levels bug you for free stuff. (yes im an autoit noob i admit it!)

In any case Thank you very much big_daddy!

Share this post


Link to post
Share on other sites

Glad I was able to help.

You may want to take a look at the IE Builder that Valuater made.

Share this post


Link to post
Share on other sites

Glad I was able to help.

You may want to take a look at the IE Builder that Valuater made.

Much appreciated. :D

Share this post


Link to post
Share on other sites

Quick question.....

How did you know about .outerText and .href ?

I dont see them anywhere on the Autoit help files

Is there a list of these that i can study?

George

Share this post


Link to post
Share on other sites

I always keep this link handy.

DHTML Properties

that should be put into the list also

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0