You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
888 B
20 lines
888 B
import urllib.request
|
|
import urllib.parse
|
|
from lxml import etree
|
|
|
|
start_page = input('开始')
|
|
end_page = input('结束')
|
|
for page in range(int(start_page),int(end_page)+1):
|
|
url='https://www.qqtn.com/tx/fengjtx_'+str(page)+'.html'
|
|
headers={'user-agent':
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36'}
|
|
request = urllib.request.Request(url=url, headers=headers)
|
|
response = urllib.request.urlopen(request)
|
|
content = response.read()
|
|
tree = etree.HTML(content)
|
|
title_list = tree.xpath('//ul[@class="g-gxlist-imgbox"]/li/a/img/@src')
|
|
name_list = tree.xpath('//ul[@class="g-gxlist-imgbox"]/li/a/img/@alt')
|
|
for i in range(len(title_list)):
|
|
name = name_list[i]
|
|
src = title_list[i]
|
|
urllib.request.urlretrieve(url=src, filename='pics/'+name+'.jpg') |