Jump to content
UBot Underground

Selecting An Element According To What It Is Not


Recommended Posts

Hi,

One of my "target" websites marks certain elements using some attribute.

For instance:

<a href="blahblah" myMarkingAttr="1">Don't click me</a>

While other links would be:

<a href="blahblah">I'm the one you want to click</a>

I want to create a list of all the <a> elements that are missing the "myMarkingAttr" attribute.

Any way to do this?

Link to post
Share on other sites

First get the links that don't contain that text on to a list like this:

clear list(%no_myattr)
clear list(%links)
add list to list(%links, $scrape attribute(<tagname="a">, "outerhtml"), "Delete", "Global")
loop($list total(%links)) {
    set(#next_link, $next list item(%links), "Global")
    if($contains(#next_link, "myMarkingAttr")) {
        then {
        }
        else {
            add item to list(%no_myattr, #next_link, "Delete", "Global")
        }
    }
}

Then when you go to get the url it will have to be extracted like this:

set(#url, $find regular expression($next list item(%no_myattr), "(?<=href=\\\").*?(?=\\\")"), "Global")
Link to post
Share on other sites

Regular Expression is your friend , I know  it's tedious and kinda scares people off

But I highly suggest you sit down for an hour or two and take the time to understand it!

 

Regex is needed a lot in ubot and having that knowledge at your disposal is always great :)

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