APTS 3 Posted July 15, 2014 Report Share Posted July 15, 2014 (edited) Hello All, Newbie here, asking what will hopefully be a simple question for someone to answer for me. I am currently using the following two lines of code to navigate to a URL and then save the browser image: navigate("http://mysite.ca/s/v/49_James_St_Toronto_Ontario_Canada", "Wait") save browser image("C:\\mypath\\browserimage.jpg")The above is working fine and saves a single image of the static address passed through the URL, but the next step is for me to incorporate this into a loop. I want to be able to loop through the list of addresses in Column 1 of the attached CSV file, and then save the browser image using the unique identifier in Column 2. Here is the data in the CSV file: 329_Lake_Promenade_Toronto_Ontario_Canada, 19190533700270024_Thirty_Seventh_St_Toronto_Ontario_Canada, 19190533800280049_James_Street_Toronto_Ontario_Canada, 19190533810190096_41st_St_Toronto_Ontario_Canada, 19190535000070011_Willowbrook_Rd_Toronto_Ontario_Canada, 191905441000006391_Melrose_St_Toronto_Ontario_Canada, 19190544400160097A_Evans_Ave_Toronto_Ontario_Canada, 191905446001610 Here is my attempt to modify some ubot code that I found elsewhere, but this is not working correctly: if($comparison(#path2list, "=", $nothing)) { then { alert("Please select list with htms ids!") stop script } } set(#pos, 1, "Global") ui open file("Load list of addresses", #path2list) clear list(%addresses) add item to list(%addresses, "", "Delete", "Global") add list to list(%addresses, $list from file(#path2list), "Delete", "Global") loop($list total(%addresses)) { navigate("http://mysite.ca/s/v/{$list item(%addresses, $subtract(#pos, 1))}", "Wait") save browser image("C:\\mypath\\browserimage.jpg") increment(#pos) } alert("Finished!") ui stat monitor("Version:", 1.0)The problem seems to be related to this: {$list item(%addresses, $subtract(#pos, 1))}The URL that is being constructed incorrectly includes a comma and the unique identifier at the end like this: http://mysite.ca/s/v/35_Fallingbrook_Dr_Toronto_Ontario_Canada,190101112000800It should be formatted like this: http://test.ptax.ca/s/v/35_Fallingbrook_Dr_Toronto_Ontario_CanadaI need to modify my code so that:it builds the correct URL without the comma and unique identifier on the end; andthe unique identifier (Column 2 data) should be used as the file name in the "save browser image" command.Thanks for any help you can offer. addresses.csv Edited July 15, 2014 by APTS Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 15, 2014 Report Share Posted July 15, 2014 give me a few be right bac 1 Quote Link to post Share on other sites
APTS 3 Posted July 15, 2014 Author Report Share Posted July 15, 2014 Ok, Copper, standing by . . . 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 15, 2014 Report Share Posted July 15, 2014 Try this if($comparison(#path2list, "=", $nothing)) { then { alert("Please select list with htms ids!") stop script }}set(#pos, "-1", "Global")ui open file("Load list of addresses", #path2list)clear list(%addresses)add list to list(%addresses, $list from file(#path2list), "Delete", "Global")loop($list total(%addresses)) { set(#adressnext item, $next list item(%addresses), "Global") navigate("http://mysite.ca/s/v/{$list item(%addresses, 0)}", "Wait") save browser image("C:\\mypath\\{$list item(%addresses, 1)}.jpg") increment(#pos)}alert("Finished!")ui stat monitor("Address List :", "{$list position(%addresses)} of {$list total(%addresses)}")ui stat monitor("Version:", 1.0) TC Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 15, 2014 Report Share Posted July 15, 2014 change that -1 to 0 I some times put the increment at the begining of the loop soo but notice everything starts at 0 not 1 Quote Link to post Share on other sites
APTS 3 Posted July 15, 2014 Author Report Share Posted July 15, 2014 Thanks for your suggestion. We have tried your code and unfortunately we are getting both columns in the url. We only want column 1 in the URL and column 2 as the file name. Are you sure we should be using "add list to list"? should we be using "add item to list"?? Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 15, 2014 Report Share Posted July 15, 2014 if($comparison(#path2list, "=", $nothing)) { then { alert("Please select list with htms ids!") stop script }}set(#pos, 0, "Global")ui open file("Load list of addresses", #path2list)clear list(%addresses)add list to list(%addresses, $list from file(#path2list), "Delete", "Global")loop($list total(%addresses)) { set(#adressnext item, $next list item(%addresses), "Global") navigate("http://mysite.ca/s/v/{$list item($list from text(#adressnext item, ","), 0)}", "Wait") save browser image("C:\\mypath\\{$list item($list from text(#adressnext item, ","), 1)}.jpg") increment(#pos)}alert("Finished!")ui stat monitor("Address List :", "{$list position(%addresses)} of {$list total(%addresses)}")ui stat monitor("Version:", 1.0) mu bad I missed the thingy in the thinga magig try that I edited the list pos for url to 0 was one Quote Link to post Share on other sites
APTS 3 Posted July 15, 2014 Author Report Share Posted July 15, 2014 Nice! Thanks Copper. I felt like I was in handcuffs for a while. I'm free! Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 15, 2014 Report Share Posted July 15, 2014 here you go, I broke it down so you can see it in the debuger I used list from text instead to show it for some reason the file was loading to list like add item to list. are you out of the US? if so your csv delimeter id L not , like moine but I checked code this time threw and works for me I had not tested it sorry clear list(%addresses)if($comparison(#path2list, "=", $nothing)) { then { alert("Please select list with htms ids!") stop script }}set(#pos, 0, "Global")add list to list(%addresses, $list from text("1.91905E+14,329_Lake_Promenade_Toronto_Ontario_Canada1.91905E+14,24_Thirty_Seventh_St_Toronto_Ontario_Canada1.91905E+14,49_James_Street_Toronto_Ontario_Canada1.91905E+14,96_41st_St_Toronto_Ontario_Canada1.91905E+14,11_Willowbrook_Rd_Toronto_Ontario_Canada1.91905E+14,391_Melrose_St_Toronto_Ontario_Canada1.91905E+14,97A_Evans_Ave_Toronto_Ontario_Canada", $new line), "Delete", "Global")loop($list total(%addresses)) { set(#adressnext item, $next list item(%addresses), "Global") set(#url list pos zero, $list item($list from text(#adressnext item, ","), 0), "Global") navigate("http://mysite.ca/s/v/{#url list pos zero}", "Wait") set(#image name pos1, $list item($list from text(#adressnext item, ","), 1), "Global") save browser image("C:\\mypath\\{#image name pos1}.jpg") increment(#pos)}ui open file("Load list of addresses", #path2list)alert("Finished!")ui stat monitor("Address List :", "{$list position(%addresses)} of {$list total(%addresses)}")ui stat monitor("Version:", 1.0) TC 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.