christojuan 5 Posted August 23, 2017 Report Share Posted August 23, 2017 (edited) Hi,the script below generates rows of results in columns B,C, and D that SHOULD align in the same rows as the data in column A BUT BCD is generated in the rows AFTER column A results are complete see: https://www.screencast.com/t/9AXG7l2Zphttps://www.screencast.com/t/BLLygP0T4hX This is all in spite of what (to me) appears to be a correct use of $newline in rows 39 and 76. Could someone please take a look and tell me how I can include the search terms in A in the aligned rows with the search terms in B,C and D?Thanks very much! clear list(%list11) clear list(%list22) clear list(%list33) clear list(%list44) clear list(%total_keywords) clear list(%total_cities) clear list(%all_keywords) if($file exists("{$special folder("My Documents")}\\search_keywords.txt")) { then { delete file("{$special folder("My Documents")}\\search_keywords.txt") } } if($file exists("{$special folder("My Documents")}\\results.csv")) { then { delete file("{$special folder("My Documents")}\\results.csv") } } ui block text("Keywords",#keywords) ui block text("Cities",#cities) ui text box("Client Url",#client_url) ui text box("Directory Url",#directory_url) save to file("{$special folder("My Documents")}\\keywords.txt",#keywords) save to file("{$special folder("My Documents")}\\cities.txt",#cities) set(#total_keywords_count,0,"Global") add list to list(%total_cities,$list from file("{$special folder("My Documents")}\\cities.txt"),"Delete","Global") add list to list(%total_keywords,$list from file("{$special folder("My Documents")}\\keywords.txt"),"Delete","Global") set(#total_cities_count,0,"Global") loop($list total(%total_keywords)) { increment(#total_keywords_count) } loop($list total(%total_cities)) { increment(#total_cities_count) } set(#second_loop,0,"Global") set(#fiirst_loop,0,"Global") loop(#total_keywords_count) { loop(#total_cities_count) { append to file("{$special folder("My Documents")}\\search_keywords.txt","{$list item(%total_keywords,#fiirst_loop)} {$list item(%total_cities,#second_loop)}{$new line}","End") increment(#second_loop) } set(#second_loop,0,"Global") increment(#fiirst_loop) } add list to list(%all_keywords,$list from file("{$special folder("My Documents")}\\search_keywords.txt"),"Delete","Global") set(#counter_for_all_keywords,0,"Global") set(#rank,0,"Global") loop($subtract($list total(%all_keywords),1)) { navigate("https://www.google.com","Wait") wait($rand(1,10)) set(#all_keywords,$list item(%all_keywords,#counter_for_all_keywords),"Global") type text(<name="q">,#all_keywords,"Standard") wait($rand(1,3)) click(<name="btnK">,"Left Click","No") wait for browser event("Everything Loaded","") increment(#counter_for_all_keywords) wait($rand(1,5)) clear list(%urls) set(#counter,0,"Global") set(#var3,0,"Global") add list to list(%urls,$scrape attribute($element child(<(tagname="h3" AND class="r")>),"href"),"Delete","Global") comment("Find google rank of url") set(#list2,0,"Global") loop($list total(%urls)) { if($contains($list item(%urls,#rank),#directory_url)) { then { add item to list(%list22,$add(#rank,1),"Don\'t Delete","Global") increment(#var3) } } increment(#rank) increment(#list2) } set(#rank,0,"Global") loop(#var3) { append to file("{$special folder("My Documents")}\\results.csv","{#all_keywords}{$new line}","End") } comment("End ") comment("Navigating to Directory url and finding client url") loop($list total(%urls)) { set(#var1,$list item(%urls,#counter),"Global") if($contains(#var1,#directory_url)) { then { set(#rank,$list position(%urls),"Global") add item to list(%list33,#var1,"Don\'t Delete","Global") navigate(#var1,"Wait") wait for browser event("Everything Loaded","") if($search page(#client_url)) { then { add item to list(%list44,"yes","Don\'t Delete","Global") } else { add item to list(%list44,"no","Don\'t Delete","Global") } } } } increment(#counter) } comment("End") } set(#last,0,"Global") set(#random_filename,$rand(1,1231232131),"Global") loop($list total(%list22)) { append to file("{$special folder("My Documents")}\\results.csv",",{$list item(%list22,#last)},{$list item(%list33,#last)},{$list item(%list44,#last)}{$new line}","End") increment(#last) } alert("Your results are in results.csv") Edited August 23, 2017 by christojuan Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted August 23, 2017 Report Share Posted August 23, 2017 hi, try something like this instead add list to list(%a,$list from text("one two three",$new line),"Delete","Global") add list to list(%b,$list from text("one two three",$new line),"Delete","Global") add list to table as column(&combined,0,0,%a) add list to table as column(&combined,0,1,%a) save to file("{$special folder("Application")}\\results.csv",&combined) Regards,CD Quote Link to post Share on other sites
christojuan 5 Posted August 24, 2017 Author Report Share Posted August 24, 2017 Awesome. Thanks very much Nick! 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.