花瓣网美女图片爬取

爬虫基础案例01

花瓣网美女图片

网站url:https://huaban.com

图片爬取

python 复制代码
import requests
import json
import os
res = requests.get(
    url= "https://api.huaban.com/search/file?text=%E7%BE%8E%E5%A5%B3&sort=all&limit=40&page=1&position=search_pin&fields=pins:PIN,total,facets,split_words,relations,rec_topic_material"
)

json_list = json.loads(res.text)["pins"];

url_list = []
for item in json_list:
    url = "https://gd-hbimg.huaban.com/" + item["file"]["key"] + "_fw480webp"
    url_list.append(url)

print(url_list)

request请求也可用params传递参数:

python 复制代码
res = requests.get(
    url= "https://api.huaban.com/search/file",
    params={
        "text":"美女+性感",
        "sort":"all",
        "limit":"100",
        "page":"1",
        "position":"search_pin",
        "fields":"pins:PIN,total,facets,split_words,relations,rec_topic_material"
    }
)

下载到本地

python 复制代码
for i in range(len(url_list)):
    path_name = "E:\pythonProject\images\\" + str(i) + ".webp"
    print(path_name)
    response = requests.get(url_list[i]);
    with open(path_name,"wb") as f:
        f.write(response.content)

查看照片:

相关推荐
Franklin11 分钟前
如何解决git HEAD detached 分离头指针问题
git·python·pycharm
deephub20 分钟前
Anthropic 开源 Bloom:基于 LLM 的自动化行为评估框架
人工智能·python·自动化·大语言模型·行为评估
万兴丶24 分钟前
批量转换音频格式工具
python
大学就业之家26 分钟前
智能选岗的陷阱与应对策略
python
chenshi178127 分钟前
安全合规:使用 RPA 批量发布时,如何规避平台封禁风险,实现长效稳定的投喂?
python
superman超哥39 分钟前
仓颉性能瓶颈定位方法深度解析
c语言·开发语言·c++·python·仓颉
岁岁的O泡奶1 小时前
NSSCTF_crypto_[SWPU 2020]happy
经验分享·python·算法·密码学
武汉唯众智创1 小时前
“物联网 Python 开发教程”课程教学解决方案
开发语言·python·物联网·物联网技术·物联网 python 开发·python 开发
时光Autistic1 小时前
【搭建教程】腾讯混元3D模型部署
开发语言·python·3d·github
前端程序猿之路1 小时前
AI大模型应用之-RAG 全流程
人工智能·python·gpt·语言模型·aigc·mybatis·ai编程