开发者

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.开发者_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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜