Jump to content
Sign in to follow this  
cypher175

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

Recommended Posts

cypher175

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

Share this post


Link to post
Share on other sites
DaleHohm

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

Share this post


Link to post
Share on other sites
Authenticity

The outer text or any part of the href?

Share this post


Link to post
Share on other sites
cypher175

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

Share this post


Link to post
Share on other sites
cypher175

so is that the right way to do this or am i missing sumthing else..??

Share this post


Link to post
Share on other sites
Authenticity

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

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  

×