|
楼主 |
发表于 2021-7-21 21:05:37
|
显示全部楼层
- import requests
- import os
- from lxml import etree
- if not os.path.exists('c:/cl'):
- os.mkdir('c:/cl')
- url = 'http://zhaoqianzhou.com/forum.php?mod=viewthread&tid=325&extra='
- UA = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'}
- respon = requests.get( url = url,headers=UA).text
- jiexi = etree.HTML(respon)
- picurl = jiexi.xpath('//div[@class="t_fsz"]//@file')
- for i in picurl:
- newpicurl = 'http://zhaoqianzhou.com/'+i
- picdate = requests.get(url=newpicurl,headers=UA).content
- picname = newpicurl.split('/')[-1]
- pinadd = 'c:/cl/'+ picname
- with open(pinadd,'wb') as tu:
- tu.write(picdate)
- print(picname,'下载完成')
复制代码 |
|