George__

StringInStr MouseClick keyword search

4 posts in this topic

How can i use StringInStr to find the word with in a webpage and click on the link like _IELinkClickByText However not having to be specific to match the full string. I cannot find this anywhere. Also how to use this on the page your are brought to after it has click on the link.

Any help will be much appreciated.

Thanks

George

Share this post


Link to post
Share on other sites



Hello @George__,

We need more info, can you show the code you have tried so far?

1 - Check if the ID/Name of the element changes, the link name may change but its possible that the ID/Name does not.

2 - What do you mean by "how to use this on the page your are brought to after it has click on the link". Use what? The same method do find the link by having the partial text?

3 - Can you share the URL?

Share this post


Link to post
Share on other sites

1 - Yes Both change

2 - Once it goes to the items page then find 'Add To Basket'

3 - Eg. http://www.currys.co.uk/gbuk/apple-iphone-6s/mobile-phones-and-accessories/mobile-phones/362_3412_32041_267_ba00011553-bv00309416/xx-criteria.html

So the Keyword would be Iphone 6s for example and for it to go to click the link

also how to make it click on the one nearest to a colour for example Rose Gold

Local $oIE = _IECreate($url)
            Local $iPosition = StringInStr($oIE, $keyword)
            MsgBox($MB_SYSTEMMODAL, "", "The search string ", $keyword ," first appears at position: " & $iPosition)
            MouseClick("left",$iPosition, 1, 1)
            ;_IELinkClickByText($oIE, $keyword)

 

Share this post


Link to post
Share on other sites

Try this:

#include <Array.au3>
#include <IE.au3>

Local $iNumLinks, $oLink, $oLinks, $asLink[0][2], $sLink_Text, $sLink_href, $aResult

Local $sSearch1 = "Condition 1"   ; In this case it will search for this two occurences, you can
Local $sSearch2 = "Condition 2"   ; put as many or few (at leat 1 offcourse) conditions you want to

Local $oIE = _IECreate("URL") ; put the URL
Sleep(5000)
_IELoadWait($oIE) ; just to make sure the website if fully loaded

Local $oLinks = _IELinkGetCollection($oIE)

MsgBox(0, "Number of Links", @extended & " links found")

For $oLink In $oLinks
    $sLink_Text = $oLink.innerTEXT
    $sLink_href = $oLink.href
    $aResult = _ArrayFindAll($asLink, $sLink_href)
    If @error Then
        ReDim $asLink[UBound($asLink)+1][2]
        $asLink[UBound($asLink)-1][0] = $sLink_href
        $asLink[UBound($asLink)-1][1] = $sLink_Text
    Else
        $asLink[$aResult[0]][1] &= " | " & $sLink_Text
    EndIf
Next

_ArrayDisplay($asLink) ; the array was reorganized to have by one side the URL an the other other all the texts that refers to that URL

For $i = 0 To UBound($asLink)-1
    If StringInStr($asLink[$i][1], $sSearch1) And StringInStr($asLink[$i][1], $sSearch1) Then
        $oIE.Navigate2($asLink[$i][0])
        Exit ; you need to change this offcourse because tou want to make a loop, i put the exit just to show this aproach.
    EndIf
Next

Exit

 

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