Jump to content

Collect Text-Links From WebPage, Click Link if Text of link Matches a Variable..?


Recommended Posts

in not sure how i should do this.. but i need to search a webpage for all its text links and if the textlink matches a specified text like "Click Me" or "Click Here" or "Click This" then i need to click which ever one of those links that it finds..

i was thinking something like using a switch but i wasn't sure what i would use for the <expression> though..??

Something like..

Switch $LinkText
        Case "Click Me" 
            _IELinkClickByText($IE, "Click Me", "", 0)
        Case "Click Here"
            _IELinkClickByText($IE, "Click Here","",0)
        Case "Click This"
            _IELinkClickByText($IE, "Click This","",0)
    EndSwitch
Link to comment
Share on other sites

Look at _IELinkGetCollection and _IEPropertyGet, innertext

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

so something like this then, or what..??

$GetLinks = _IELinkGetCollection($IE)
For $Link in $GetLinks
   $LinkText = _IEPropertyGet($Link, "outertext")
   Switch $LinkText
        Case "Click Me"
            _IELinkClickByText($IE, "Click Me", "", 0)
        Case "Click Here"
            _IELinkClickByText($IE, "Click Here","",0)
        Case "Click This"
            _IELinkClickByText($IE, "Click This","",0)
    EndSwitch
Next
Link to comment
Share on other sites

I think Select...Case...EndSelect is more appropriate because you can specify just a part of the string instead of a full case-insensitive match. Like:

For $oLink In $oLinks
    $sOuterText = _IEPropertyGet($oLink, 'outertext')
    Select
         Case StringInStr($sOuterText, 'click me')
           ; ....
         Case StringInStr($sOuterText, 'click here')
           ; ....
    EndSelect
Next
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...