PRO 69 Posted January 12, 2016 Report Share Posted January 12, 2016 (edited) Hi Fellow Botters, as I am pretty new to ubot I am facing a general problem of not knowing how to implement the following. What I try to achieve is:1.) I provide a list of URLs within a TXT file or CSV2.) The bot should load the list after start3.) The bot should execute a normal ubot script but for each URL only once4.) After executing the script (or loop) for all the given URLs, we take the result data and store it as CSV or TXT What I need most help with are step 2 and 3. Mayve I miss an idea how to tell the bot take each from TXT list and loop ubot script until all urls are processed. If anyone can give me a headstart on how to achieve this would be awesome.. Thanks! Edited January 12, 2016 by PRO Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 12, 2016 Report Share Posted January 12, 2016 Here you go ui open file("List of urls",#urls) comment("Make sure they uploaded a list of urls, let them know if they didn\'t!") if($is blank(#urls)) { then { alert("Please load a list of urls first") stop script } else { } } comment("Make sure your lists and tables get cleared out before each run to avoid problems if they decide to use the program over and over") clear list(%urls) add list to list(%urls,$list from file(#urls),"Delete","Global") clear table(&data) comment("Set the table row number, we will use this in the \"Set Table Cell\" commands below Number starts at 0 because 0 is the first number counted in programming so row 0 is the first row and 1 is the second and so on") set(#row,0,"Global") comment("List total is the number of items in the list if we loop for the list total then it will automatically loop for the correct number") loop($list total(%urls)) { comment("Use next list item to get the next item in the list automatically") navigate($next list item(%urls),"Wait") set table cell(&data,#row,0,$url) set table cell(&data,#row,1,$title) set table cell(&data,#row,2,$meta description) set table cell(&data,#row,3,$meta keywords) comment("Increment the row number now so that in the CSV file the next website info will be stored on the next line") increment(#row) } set(#save_location,"{$special folder("Desktop")}\\Data.csv","Global") save to file(#save_location,&data) alert("Website info saved to {#save_location}") 3 Quote Link to post Share on other sites
PRO 69 Posted January 12, 2016 Author Report Share Posted January 12, 2016 (edited) I just reloaded this page here on the forum and BOOOOOM! The detailled and exact plan to achieve is flying in! You are a bomb @HelloInsomnia for a ninja fast termination of my unwanted problem. If it works Have many thanks! P.S.: I wanted to press "LIKE" for your answer but unfortunately the forum tells me: An error occurredYou have reached your quota of positive votes for the dayI will virtually thank you tomorrow then Edited January 12, 2016 by PRO 1 Quote Link to post Share on other sites
Brutal 164 Posted January 12, 2016 Report Share Posted January 12, 2016 Pro, you should also check out the "with each" command. I'm loving it - It makes looping about as simple as it can get. 1 Quote Link to post Share on other sites
PRO 69 Posted January 12, 2016 Author Report Share Posted January 12, 2016 Hi Brutal, sounds good, I ll definetly remind your advice and check out this command as well. Have thanks! Quote Link to post Share on other sites
PRO 69 Posted January 12, 2016 Author Report Share Posted January 12, 2016 Here you go ui open file("List of urls",#urls) comment("Make sure they uploaded a list of urls, let them know if they didn\'t!") if($is blank(#urls)) { then { alert("Please load a list of urls first") stop script } else { } } comment("Make sure your lists and tables get cleared out before each run to avoid problems if they decide to use the program over and over") clear list(%urls) add list to list(%urls,$list from file(#urls),"Delete","Global") clear table(&data) comment("Set the table row number, we will use this in the \"Set Table Cell\" commands below Number starts at 0 because 0 is the first number counted in programming so row 0 is the first row and 1 is the second and so on") set(#row,0,"Global") comment("List total is the number of items in the list if we loop for the list total then it will automatically loop for the correct number") loop($list total(%urls)) { comment("Use next list item to get the next item in the list automatically") navigate($next list item(%urls),"Wait") set table cell(&data,#row,0,$url) set table cell(&data,#row,1,$title) set table cell(&data,#row,2,$meta description) set table cell(&data,#row,3,$meta keywords) comment("Increment the row number now so that in the CSV file the next website info will be stored on the next line") increment(#row) } set(#save_location,"{$special folder("Desktop")}\\Data.csv","Global") save to file(#save_location,&data) alert("Website info saved to {#save_location}") HelloInsomnia, your given script works perfectly without modification. Also it explains the whole process of how ubot logic is handling such routines known from common programming languages. Thanks mate! I salute you Quote Link to post Share on other sites
Brutal 164 Posted January 12, 2016 Report Share Posted January 12, 2016 ui block text("urls - one per line",#urls)add list to list(%url_list,$list from text(#urls,$new line),"Delete","Global")with each(%url_list,#current_url) { navigate(#current_url,"Wait") wait for browser event("Everything Loaded","") comment("Now it has loaded a url - Tell it what to do under this comment box") set(#my_results,$title,"Global") add list to list(%titles,$list from text(#my_results,$new line),"Delete","Global")}save to file("{$special folder("Desktop")}\\my-ubot-stuff.txt",%titles) Quote Link to post Share on other sites
PRO 69 Posted January 12, 2016 Author Report Share Posted January 12, 2016 (edited) Haha, welcome to developers heaven, to prepare for the market hell out there - where incoming special forces jump in to save your day Awesome, thanks for also sharing your style of Kung Fu, Mr. Brutal Lee P.S.: I wanted to press "LIKE" for your answer but unfortunately the forum tells me: An error occurredYou have reached your quota of positive votes for the dayI will virtually thank you tomorrow then Edited January 12, 2016 by PRO Quote Link to post Share on other sites
arc323 2 Posted July 24, 2016 Report Share Posted July 24, 2016 Huge thank you to HelloInsomnia! This is exactly what I needed. Cheers! 1 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.