精易论坛

标题: 爬取壁纸网站(练手请勿滥用) [打印本页]

作者: aini1wna2    时间: 2023-4-16 15:56
标题: 爬取壁纸网站(练手请勿滥用)
只要用来练手的,勿喷。
[Python] 纯文本查看 复制代码
import requests
import re
url = 'https://www.bizhi88.com/3840x2160/'
headers = {
        '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=headers)
response.encoding = 'utf8'
html_info = re.findall('<a href="(.*?)" title="(.*?)" target="_blank" class="img" style="(.*?)"', response.text)
num = 0
for link, title, style in html_info:
    num = num + 1
    if num == 1:
        continue
    link_url = 'https://www.bizhi88.com' + link
    response2 = requests.get(url=link_url, headers=headers)
    response2.encoding = "utf8"
    img_url = re.findall('<img src="(.*?)" alt="(.*?)"', response2.text)[0]
    print(img_url[0], img_url[1])
   


作者: 精彩的鸟    时间: 2023-4-16 16:44
请用易语言
作者: 宇晨CC    时间: 2023-4-16 17:13
不如https://wallhaven.cc/
作者: aini1wna2    时间: 2023-4-16 18:12
宇晨CC 发表于 2023-4-16 17:13
不如https://wallhaven.cc/

练手 随手找到 一个国内的  当然还有很多比他强的
作者: jysoft2022    时间: 2023-4-16 21:23
感谢分享




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4