Jump to content
UBot Underground

Regex And Element Selector Using Variable


Recommended Posts

Hi,

 

Hope I can expain this clearly.

 

I have a list of links on page and a spreadsheet with text that partially matches the links,

 

Example Link:

manchester-park-centre123

 

Example text:

manchester-park-centre

 

I want ubot the click on the link that partially matches the text. When I enter the text manually using regex it works fine. But when I pull the same text from a variable it causes a code error.

 

Anything I need to add to the code so that It can use variables?

 

Thanks for any help with this.

 

Link to post
Share on other sites

my regex really sucks and is very basic,so I rely on scraping for the most part,like this

load html("<a href=\"/manchester-park-centre.html\">manchester</a></BR>
<a href=\"/centre.html\">1</a></BR><a href=\"/park-centre.html\">2</a>")
set(#myLink text, "manchester-park-centre", "Global")
set(#position, 0, "Global")
add list to list(%hrefs, $scrape attribute(<tagname="a">, "href"), "Delete", "Global")
loop while($comparison(#position, "<", $list total(%hrefs))) {
    if($comparison($find regular expression($list item(%hrefs, #position), #myLink text), ">", $nothing)) {
        then {
            click(<href=$list item(%hrefs, #position)>, "Left Click", "No")
            set(#position, $list total(%hrefs), "Global")
        }
        else {
            increment(#position)
        }
    }
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...