Jump to content

Recommended Posts

Posted (edited)

Hello,

I want to get links and open a new IE window only if the text link is "p/stats".

$oIE = _IECreate($url)
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    If $oLink.innerText = "p/stats" Then
        $oIEstats = _IECreate($oLink.href)
        MsgBox(0, "Link", $oLink.innerText & " - " & $oLink.href)
        _IEQuit($oIEstats)
    EndIf
Next

This code works and i see the msgbox with text and href.

But it open all links and not only the link with the specific text :)

Need help please, where i fail ?

Thx :)

Edited by gimx
  • Moderators
Posted (edited)

Hello,

I want to get links and open a new IE window only if the text link is "p/stats".

$oIE = _IECreate($url)
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    If $oLink.innerText = "p/stats" Then
        $oIEstats = _IECreate($oLink.href)
        MsgBox(0, "Link", $oLink.innerText & " - " & $oLink.href)
        _IEQuit($oIEstats)
    EndIf
Next

This code works and i see the msgbox with text and href.

But it open all links and not only the link with the specific text :)

Need help please, where i fail ?

Thx :)

Just because you quit IE doesn't mean that the links aren't still in memory in the loop.

After _IEQuit(), put ExitLoop.

Edit:

Actually, what's up with the _IECreate() in the loop?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

are you looking for if the text says that, or if it INCLUDES that + afew more letters the latter could be used by Stringinstr() and stringtrimleft() hwat exactly are you looking for?

Posted

Thx for replies.

Imagine you have a webpage like this :

<a href="http://blablabla.com">blablabla</a>
<a href="http://poopoopidoo.com">poopoopidoo</a>
<a href="http://blablabla.com">blablabla</a>
<a href="http://poopoopidoo.com">poopoopidoo</a>
<a href="http://blablabla.com">blablabla</a>

I want to get the link only if the text is "blablabla"

Actually if i use this code, autoit get all links and msgboxs appear with all links.

The first msgbox say : blablabla - http://blablabla.com

The second : poopoopidoo - http://poopoopidoo.com

Etc...

But i want only msgbox with blablabla like this.

The first msgbox say : blablabla - http://blablabla.com (click ok, loop continue an 2nd appear)

The second msgbox say : blablabla - http://blablabla.com (click ok)

The third : blablabla - http://blablabla.com (click ok, loop finish)

$oIE = _IECreate($url)
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    If $oLink.innerText = "blablabla" Then
        MsgBox(0, "Link", $oLink.innerText & " - " & $oLink.href)
    EndIf
Next
Posted

Solved with String function.

If String($oLink.innerText) = "blablabla" Then

Or

If StringInStr($oLink.innerText, "blablabla") Then

Depend what you want.

Thx for replies :)

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
×
×
  • Create New...