[Python] 纯文本查看 复制代码 import requests
import parsel
import os #1069 2145
url='https://www.yituyu.com/gallery/1069/'
headers={'user-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' }
try:
path=os.getcwd()
file_path=path+'\\'+'4k写真'
os.mkdir(file_path)
except:
pass
x=1069
while(x<2146):
y=1
urls='https://www.yituyu.com/gallery/'+str(x)+'/'
FIRst=requests.get(urls,headers).text
selector=parsel.Selector(FIRst)
url=selector.xpath('//div[@class="gallerypic"]/img/@data-src').getall()
name=selector.xpath('//div[@class="gallerypic"]/img[1]/@alt').get()
for i in url:
LASt=requests.get(i,headers).content
with open(f'{file_path}\\{name}'+str(y)+'.jpg','wb')as f:
f.write(LASt)
print('正在写入:'+name)
y+=1
x+=1 |