博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
批量下载图片
阅读量:7217 次
发布时间:2019-06-29

本文共 951 字,大约阅读时间需要 3 分钟。

# -*- coding: UTF-8 -*-import requestsimport timeimport osfrom bs4 import BeautifulSouptitles = {}page = 3path = "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/5b3aca2b518825620547124f

你可能感兴趣的文章
大型分布式网站架构技术总结
查看>>
矩阵求导与投影梯度相关问题
查看>>
SVN
查看>>
C语言编程写的一个http下载程序(王德仙)2012-04-08
查看>>
CCF201409-3 字符串匹配(100分)
查看>>
UVALive2203 UVa10042 Smith Numbers【质因数分解+素数判定+数位之和】
查看>>
Project Euler Problem 9: Special Pythagorean triplet
查看>>
HDU5701 中位数计数【中位数】
查看>>
Python 深浅拷贝 (Shallow copy and Deep copy in Python)
查看>>
Axure
查看>>
屏幕截取工具
查看>>
C语言第七次作业---要死了----
查看>>
Jquery事件绑定冲突
查看>>
偶现bug如何处理?
查看>>
yum命令简介
查看>>
【Udacity】朴素贝叶斯
查看>>
看漫画,学 Redux
查看>>
Spark Streaming揭秘 Day19 架构设计和运行机制
查看>>
【转载】WinCE OAL中的电源管理函数
查看>>
【iOS】Objective-C简约而不简单的单例模式
查看>>