马上登陆,加入晨风
您需要 登录 才可以下载或查看,没有账号?立即注册
×
哈哈,大家好我是怨黎,小梨子~~~ !
星期天闲的没有事情可做
于是我就开始捣鼓代码了
然后。。。。。
无意中写出了批量下载斗图啦的程序
无聊之作,但是运行效率还是很高滴!
“No picture you say a J8啊!”对不对?
一定有图有真相哈。。。
上图:
上代码:[Python] 纯文本查看 复制代码 import requests as r[/align]
import urllib
import re
import os
script_path = os.path.realpath(__file__)
script_dir = os.path.dirname(script_path)
def getapage(url):
headers = {
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"}
html = r.get(url, headers=headers).text
regex = """<img src="//static.doutula.com/img/loader.gif" style="width: 100%; height: 100%;" data-original="(.*?)" alt="(.*?)" class="img-responsive lazy image_dta" data-backup"""
resulit = re.findall(regex, html)
return resulit
if not os.path.exists(script_dir + '/imgs'):
os.mkdir(script_dir + '/imgs')
for i in range(1,1959+1):
resulit=getapage("http://www.doutula.com/photo/list/?page="+str(i))
print("正在获取第"+str(i)+"页")
for imgs in resulit:
o = open(script_dir + "/imgs/" + imgs[1] + ".gif", "wb")
img = urllib.request.urlopen(imgs[0])
o.write(img.read())
o.close()
小弟不奢侈money!!!要的是别喷me。。。。。
溜啦,溜啦!
|