201180721 从豆瓣图书 Top 250下载所有图片

#!/usr/bin/env python
# encoding: utf-8
#导入模块
import re
import urllib
from bs4 import BeautifulSoup

f=urllib.urlopen('https://book.douban.com/top250?start=225')
htmlCode = f.read()
htmlCode.find('src')
imageList=re.findall(r'src="(.*?\.(jpg|png))"',htmlCode)
j=1
for i in imageList :
imageUrl = i[0]
urllib.urlretrieve(imageUrl,'./images/%d.jpg'%j)
j+=1

posted on 2018-07-21 17:06  keawen  阅读(113)  评论(0)    收藏  举报

导航