Jump to content

Need help finding the last item in a search?


eskay
 Share

Recommended Posts

Im trying to click a link in a website.. The only problem is that its named "Reply" and each post on the forum has "Reply" in it. So the webpage has tons of "Reply" links but I want to click on the last one.

So how can I search and click the Last "Reply" link that is found?

Link to comment
Share on other sites

Im trying to click a link in a website.. The only problem is that its named "Reply" and each post on the forum has "Reply" in it. So the webpage has tons of "Reply" links but I want to click on the last one.

So how can I search and click the Last "Reply" link that is found?

Look at the _IE functions. Then see how you go about finding the links. The other part can come later :P
Link to comment
Share on other sites

  • Moderators

Here is an example...

#include <IE.au3>

$sURL = "http://www.msn.com/"
$sSearchText = "photo"

$oIE = _IECreate($sURL)
_IELinkClickLast($oIE, $sSearchText)
If @error Then
    MsgBox(0, "", "No links matched your search string.")
EndIf

Func _IELinkClickLast(ByRef $o_object, $s_SearchText)
    $o_Links = _IELinkGetCollection($o_object)
    $i_Count = @extended
    For $i = ($i_Count - 1) To 0 Step - 1
        $s_LinkText = String($o_Links.item($i).outerText)
        If StringInStr($s_LinkText, $s_SearchText) Then
            _IELinkClickByIndex($o_object, $i)
            Return 1
        EndIf
    Next
    Return SetError(1, 0, 0)
EndFunc   ;==>_IELinkClickLast
Link to comment
Share on other sites

Elegant and Cool!

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

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