天堂图片网图片下载
import requests from lxml import etree import urllib url = 'http://www.ivsky.com/tupian/ziranfengguang/' def Schedule(blocknum,blocksize,totolsize): per = 100.0 * blocknum * blocksize / totolsize if per > 100: per = 100 print('当前下载进度:%d' % per) headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/57.0'.encode('utf-8')} r = requests.get(url,headers=headers) html = etree.HTML(r.text) img_urls = html.xpath('.//img/@src') i = 0 for img_url in img_urls: urllib.request.urlretrieve(img_url,'img//img'+str(i)+'.jpg',Schedule) i+=1