网站url:https://huaban.com
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传递参数:
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"
}
)
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)