Jump to content
UBot Underground

Loop list of URLs then save each screen image with unique name


Recommended Posts

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, 191905337002700

24_Thirty_Seventh_St_Toronto_Ontario_Canada, 191905338002800

49_James_Street_Toronto_Ontario_Canada, 191905338101900

96_41st_St_Toronto_Ontario_Canada, 191905350000700

11_Willowbrook_Rd_Toronto_Ontario_Canada, 191905441000006

391_Melrose_St_Toronto_Ontario_Canada, 191905444001600

97A_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,190101112000800

It should be formatted like this:

http://test.ptax.ca/s/v/35_Fallingbrook_Dr_Toronto_Ontario_Canada

I need to modify my code so that:

  • it builds the correct URL without the comma and unique identifier on the end; and
  • the 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 by APTS
Link to post
Share on other sites

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

Link to post
Share on other sites

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"??

Link to post
Share on other sites

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

Link to post
Share on other sites

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_Canada
1.91905E+14,24_Thirty_Seventh_St_Toronto_Ontario_Canada
1.91905E+14,49_James_Street_Toronto_Ontario_Canada
1.91905E+14,96_41st_St_Toronto_Ontario_Canada
1.91905E+14,11_Willowbrook_Rd_Toronto_Ontario_Canada
1.91905E+14,391_Melrose_St_Toronto_Ontario_Canada
1.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

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...