Sign in to follow this  
Followers 0
sumone4life

_IE dynamic links question

5 posts in this topic

I am making a bot for a website and on this website there is a list of links that are generated dynamically. Now the quantity of links changes and the location they point to changes but they all have one thing in common... they start with view.php

Im looking for a way to click those links one at a time until it goes through the whole list of them. Is there a way to do that with _IE... possible use _IELinkGetCollection and then search for a text string?

Share this post


Link to post
Share on other sites



I am making a bot for a website and on this website there is a list of links that are generated dynamically. Now the quantity of links changes and the location they point to changes but they all have one thing in common... they start with view.php

Im looking for a way to click those links one at a time until it goes through the whole list of them. Is there a way to do that with _IE... possible use _IELinkGetCollection and then search for a text string?

Use _IELinksGetCollection(), but as soon as you click on one they will all become invalid when the browser changes pages. You have to save the links (like in an array) and click through them there. Even that may not work, because once you have navigated away from the page they came off of any java script or other stuff needed may not be available. Perhaps opening each link in a separate tab (if IE7) would help.

This code gets the links, anyway:

#include <IE.au3>
#include <array.au3>

Dim $avLinks[1]
$sURL = "www.autoitscript.com"

$oIE = _IECreate($sURL, 1)
$colLinks = _IELinkGetCollection($oIE)
ConsoleWrite("Debug: Returned " & @extended & " links." & @LF)
For $oLink In $colLinks
    _ArrayAdd($avLinks, $oLink.href)
Next
$avLinks[0] = UBound($avLinks) - 1

_ArrayDisplay($avLinks, "Debug: $avLinks")

:)


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

Well... there are main links on the page and then an array of links generated by a php script. It doesnt use javascript for the link that im aware of. target="_blank" so it opens in a new window anyway. Really my question is... after loading the links into an array... how to i go through and remove all the ones that dont have or start with view.php?

Share this post


Link to post
Share on other sites

Well... there are main links on the page and then an array of links generated by a php script. It doesnt use javascript for the link that im aware of. target="_blank" so it opens in a new window anyway. Really my question is... after loading the links into an array... how to i go through and remove all the ones that dont have or start with view.php?

Is that part of the href string that is in the array generated by my previous post? If so, then it's just a tweak to the loop:

For $oLink In $colLinks
    $sHref = $oLink.href
    If StringInStr($sHref, "view.php") Then _ArrayAdd($avLinks, $sHref)
Next

:)


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

wonderful that will work. Thank you

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  
Followers 0