# -*- coding: UTF-8 -*-
import requests
import time
import os
from bs4 import BeautifulSoup
titles = {}
page = 3
path = "http://findicons.com"
response = requests.get("http://findicons.com/pack/" + str(page) + "")
soup = BeautifulSoup(response.content, "html.parser")
# 根据标题Key,详情页为内页
for item in soup.select(".inner"):
titles[item.select("a")[0]['title']] = path + item.select("a")[0]['href']
for i in titles:
dirName = i
os.makedirs("img/" + dirName)
path = titles[i]
imgResponse = requests.get(path)
soup = BeautifulSoup(imgResponse.content, "html.parser")
for imgitem in soup.select(".iconenter"):
imgurl = imgitem.select("img")[0]['src']
downImageResponse = requests.get(imgurl)
if downImageResponse.status_code == 200:
with open("img/" + dirName + "/" + str(time.time()) + ".png", "wb") as file:
file.write(downImageResponse.content)
复制代码
转载于:https://juejin.im/post/5b3ac88de51d45556a1bc142
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/101580.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...