awesome sauce 0 Posted February 3, 2016 Report Share Posted February 3, 2016 I was just wondering if it's possible to clean your data with UBot? For example, say you have a list with mostly the same URLs, but some of those URLs are also from different domains. Can you tell UBot to remove URLs from the list if they don't contain 'google.com'? How would this look in code? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted February 3, 2016 Report Share Posted February 3, 2016 A few ways to do it but I think you will find using a second list is the easiest: clear list(%urls) add list to list(%urls,$list from text("http://yahoo.com,http://google.com,http://pinterest.com,http://ubotstudio.com",","),"Delete","Global") clear list(%urls_cleaned) loop($list total(%urls)) { set(#list_item,$next list item(%urls),"Global") if($contains(#list_item,"google.com")) { then { add item to list(%urls_cleaned,#list_item,"Don\'t Delete","Global") } else { } } } Quote Link to post Share on other sites
awesome sauce 0 Posted February 3, 2016 Author Report Share Posted February 3, 2016 (edited) OMG thank you so much! That works perfectly and really saves me some time scraping data. Is it also possible just to clean the 'urls' list without making another list? I know you said the way above it likely easiest, but I like to know other ways to do things as well. Edited February 3, 2016 by awesome sauce Quote Link to post Share on other sites
HelloInsomnia 1103 Posted February 3, 2016 Report Share Posted February 3, 2016 Give this a try: clear list(%urls) add list to list(%urls,$list from text("http://yahoo.com,http://google.com,http://pinterest.com,http://ubotstudio.com",","),"Delete","Global") loop($list total(%urls)) { set(#list_item,$next list item(%urls),"Global") if($contains(#list_item,"google.com")) { then { } else { set list position(%urls,$subtract($list position(%urls),1)) remove from list(%urls,$list position(%urls)) } } } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.