[Python] 纯文本查看 复制代码 from asyncore import write
import requests , random , os
from lxml import etree
def write(url):
res = requests.get(url=url).text
bodyXML = etree.HTML(res)
imgList = bodyXML.xpath('//span[@class="bannerfix-wrapper"]/img/@data-src')
title = bodyXML.xpath('//div[@id="mod-common"]/@data-article-title')[0]
for item in imgList:
with open(f'./img/{title}-{random.randint(0,9999)}.jpg',mode='wb') as fs:
fs.write(requests.get(url='https:'+item).content)
fs.close()
def mkdir():
static=os.path.exists('./img')
if not static:
os.makedirs('./img')
return True
else:
return False
[attach]2541489[/attach]
if __name__ == '__main__':
mkdir()
url = input('请输入网址:')
write(url) 看到QQ看点有漂亮小姐姐,然后就在东拼西凑地找代码片段组合,就写下了以下的代码(大佬绕开) |
|