Justjoe
Justjoe

Reputation: 381

I am writing a scraper that downloads all the image files from a multiple pages across the same site and saves them to a specific folder

the pages have only one variable which changes, and each page only holds one image.

(example: http://www.example.com/photos/ooo1.jpg ...http://www.example.com/photos/1745.jpg)

I'm currently building the script with python and beautfulSoup but am having a problem creating a loop with the changing variable. I just getting started with python, so thanks for the help.

Upvotes: 0

Views: 206

Answers (1)

Eric Fortin
Eric Fortin

Reputation: 7603

for i in xrange(1, 1746):
    file = urllib2.urlopen("http://www.example.com/photos/%04d.jpg" % i)
    ...
    # Write file locally
    ...

You don't need Beautiful soup if you already know the image urls.

Upvotes: 1

Related Questions