python爬取精美壁纸
import requestsfrom lxml import etreeimport time
url = "https://desk.3gbizhi.com/deskDM/"
headers1 = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36'
}
response = requests.get(url=url,headers=headers1)
#print(response.text)
tree = etree.HTML(response.text)
list = tree.xpath("/html/body/div/ul/li/a/@href")
for i in list:
print(i)
response1 = requests.get(i)
tree1 = etree.HTML(response1.text)
id = tree1.xpath("/html/body/div/h2/text()")
url_source = tree1.xpath("/html/body/div/div/a/@href")#/html/body/div/div/a
#print(id,url_source)
url1 = url_source
#print(url1)
img_source = requests.get(url1)
#下载
with open('img//' + '3G_dongman_wp//' + id + '.jpg', mode="wb") as f:
f.write(img_source.content)
print("oveer!")
time.sleep(0.1)
response1.close()
response.close()
谢谢这些妹子,让我又来了一发 爬取精美壁纸.py
Traceback (most recent call last):
File "C:/Users/Administrator/AppData/Local/Programs/Python/Python37/python爬取精美壁纸.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
不懂,请老师解疑 水平用到机智了 无脑复制运行一下,有warning 感谢分享! feiyu361 发表于 2022-12-24 15:30
谢谢这些妹子,让我又来了一发
老哥,论坛里没有你认识的人了吗 感谢分享
不错,好像就是一个列表的:lol 一看代码里面写的xpath的路径就知道帖主是一个严谨的爬虫入门者。哈哈 喔哦,喔哦,技术不就来了啊