开发者

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

开发者 https://www.devze.com 2023-01-18 11:31 出处:网络
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.开发者_JAVA技巧example.com/photos/1745.jpg)

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.开发者_JAVA技巧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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号