Jump to content

clicking a link on a site


Recommended Posts

I am trying to click on the "Export to CSV" link at the middle of the page. I think the script is working but Internet Explorer seems to be blocking the click action?

I get the a information bar at the top, "IE has blocked this site from downloading files to your computer"

But if I manually click the link it works.

Reason why I know I'm close is because the my ConsoleWrite results show the link I'm looking for - "Export to CSV"

It's a free website - no need for login

#include <ie.au3>
#include <array.au3>

GetInfo()

Func GetInfo()

    _IEErrorHandlerRegister("Custom_COM_Error")

    $oIE = _IECreate("http://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=y&type=8&season=2011&month=0&season1=2011&ind=0", 0, 1)

    _IELoadWait($oIE)

    $sMyString = "Export to CSV"

    $oLinks = _IELinkGetCollection($oIE)

    For $oLink In $oLinks
        $sLinkText = _IEPropertyGet($oLink, "innerText")
        ConsoleWrite($sLinkText & @CRLF)
        If StringInStr($sLinkText, $sMyString) Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next

;~  _IEQuit($oIE)

    _IEErrorHandlerDeRegister()

EndFunc   ;==>GetInfo

Func Custom_COM_Error()

;~  MsgBox(0, "", $Custom_COM_Error.Description & @CRLF & _
;~          "" & @CRLF & _
;~          "Script Line: " & $Custom_COM_Error.ScriptLine)

    $COM_Error = 1

EndFunc   ;==>Custom_COM_Error
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...