Jump to content
UBot Underground

Wildcards in Remove List Item


Recommended Posts

I have scraped a list of URLs, but I want to remove any URL from a specific domain.

 

Example:

 

 

google.com/qwerqwere.html

googe.com/o121302.html

bob.com/yeay

 

I would like to remove all teh domains that have Google from the list.

 

I have tried doing a few things, but it seems that you can't wildcard it.

 

HELP!!

Link to post
Share on other sites
  • 6 years later...

Really sucks that ubot has to declare all lists before runtime, and custom functions cannot return a list or even as a parameter argument, Ubot should be smart enough to know its returning a Ubot list in the function, I have reported this years ago and was informed it is not a bug, and to place a feature request

 

however this should be what your looking for

define $ListRemove(#list, #query) {
    add list to list(%TheList,$list from text(#list,$new line),"Don\'t Delete","Local")
    set(#position,$subtract($list total(%TheList),1),"Local")
    loop($list total(%TheList)) {
       if($contains($list item(%TheList,#position),#query)) {
            then {
                remove from list(%TheList,#position)
                decrement(#position)
            }
            else {
                decrement(#position)
            }
        }
    }
    return(%TheList)
}
add list to list(%URLs,$list from text("google.com/qwerqwere.html
googe.com/o121302.html
bob.com/yeay",$new line),"Don\'t Delete","Global")
add list to list(%CleanedList,$list from text($ListRemove(%URLs, "google.com"),$new line),"Don\'t Delete","Global")
  
  • Like 2
Link to post
Share on other sites

Thanks @deliter.  You always come to the rescue.  I figured it out right after.  I did mine a little different.  I loaded the list and did the if $contains deal and whatever was true I added it to another list.  Then at the end I took the two lists and made a third list from using the $subtract lists

 

You rock.

  • Like 2
Link to post
Share on other sites

Here is another way,

comment("you can use a $read file function to read in the file of urls
or use a variable insted
put in place of urls inside \"Original Text\"

also use a #varible in place of the root domain
or use $next list item

#var.*
The . is a character and the star is to the end of the line.")
clear list(%urls)
add list to list(%urls,$list from text($replace regular expression("google.com/qwerqwere.html
googe.com/o121302.html
bob.com/yeay
google.com/sbljdlekjlj","google.com.*",$nothing),$new line),"Delete","Global")
alert(%urls)
comment("can look like this")
set(#domain to remove,"google.com","Global")
clear list(%urls_2)
add list to list(%urls_2,$list from text($replace regular expression("google.com/qwerqwere.html
googe.com/o121302.html
bob.com/yeay
google.com/sbljdlekjlj","{#domain to remove}.*",$nothing),$new line),"Delete","Global")
alert(%urls_2)

Regards,
Nick

remove url from list.ubot

  • Like 2
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...