用python批量下载图片
2016-01-26 13:20
447 查看
#下载知乎上的图片 from urllib.request import urlopen from urllib.request import urlretrieve from bs4 import BeautifulSoup import re def getUrl(url): html=urlopen(url) bsObj=BeautifulSoup(html,"html.parser") links=bsObj.findAll('img',src=re.compile('pic.*zhimg.com/[a-z 0-9]*_b\.(jpg|png)')) i=0 for link in links: i+=1 print(link.attrs['src']) path='E:/'+str(i)+'.jpg' urlretrieve(link.attrs['src'],path) getUrl('https://www.zhihu.com/question/40007169#answer-29511584')
相关文章推荐
- Educational Codeforces Round 4 A题 (python进行字符串的划分)
- 基于Python的Grib数据可视化
- Python 爬虫入门(二)—— IP代理使用 - 不剃头的一休哥 - 博客园
- Python【基础第二篇】
- Python3入门基础语法总结
- python 多线程就这么简单(续)
- python 多线程就这么简单
- Python生成器表达式
- python中的编码知识整理汇总
- Python导入第三方模块后eclipse提示unresolved import
- python模块系列之 - re
- python quick start
- Python openpyxl Read
- Python列表解析
- Python RawSocket Syn
- 我开始学python了(4)
- python 调试 pdb
- Python 并行任务技巧
- python的简单入门
- 【python】print "hello" SyntaxError: Missing parentheses in call to 'print'