Jump to content
Sign in to follow this  
gcue

clicking a link on a site

Recommended Posts

gcue

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

Share this post


Link to post
Share on other sites
PsaltyDS

Look at Example 2 in the help file under _IEAction(). Set focus on the link and then ControlSend() to it.

:)


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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.