Jump to content

Find Links in page


Recommended Posts

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
    $sTxt &= $oLink.href & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)

 

This is work for only this url, But did not work other urls like "https://tools.usps.com/go/ZipLookupAction!input.action"

I get the error as below

Variable must be of type "Object".:

For $oLink In $oLinks
For $oLink In $oLinks^ ERROR

 

Please suggest.

Link to comment
Share on other sites

Try:
 

#include <IE.au3>
#include <MsgBoxConstants.au3>

Global Const $iLink = "https://tools.usps.com/go/ZipLookupAction!input.action"

Local $oIE = _IECreate($iLink)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "!", "_IECreate Error: " & @error)
Local $oLinks = _IELinkGetCollection($oIE)
Local $iError = @error
Local $iNumLinks = @extended
If Not $iError And IsObj($oLinks) Then
    Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
        $sTxt &= $oLink.href & @CRLF
    Next
    MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)
Else
    Exit MsgBox($MB_SYSTEMMODAL, "!", "Get Link Error: " & $iError)
EndIf

 

Regards,
 

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...