清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
import urllib.request import re import threading images=[] def touchImages(): url='http://www.qiushibaike.com/imgrank' req=urllib.request.Request(url,headers={'User-Agent':'Mozilla/5.0'}) res=urllib.request.urlopen(req) html=res.read().decode('utf8') rule=re.compile('<img src="(.?)" alt="(.?)" />') return rule.findall(html) class downImg(threading.Thread): def init(self): threading.Thread.init(self) def run(self): global images while images: image=images.pop() link=image[0] imgType=link.split('.')[-1] name=image[1]+'.'+imgType with open(name,'wb') as f: f.write(urllib.request.urlopen(link).read()) def multiDown(n): global images images+=touchImages() print('一共有'+str(len(images))+'张糗百图片') for i in range(n): a=downImg() a.start() if name=='main': multiDown(10) #开10个线程去下载