Python学习笔记:Python网络爬虫,实现爬取网络图片
来源:互联网 发布:东北 校园网络电视 编辑:程序博客网 时间:2024/06/05 03:28
本文主要通过Python爬取百度壁纸的图片
程序代码:
import urllib
import re
def GetHtml(url):
page = urllib.urlopen(url)
html = page.read();
return html
def GetImg(html):
reg = '"((http|ftp)s?://.*?)"'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
x=0
for imgurl in imglist:
str=imgurl[0]
if str.find(".jpg")==-1:
continue
try:
urllib.urlretrieve(str,"%s.jpg"% x)
x+=1
except :
continue
def ReadHtmlText(urlStr):
html = urllib.urlopen(urlStr)
print(html.read())
htmltex=GetHtml("http://image.baidu.com/search/index?ct=201326592&tn=baiduimage&word=%E5%A3%81%E7%BA%B8%20%E4%B8%8D%E5%90%8C%E9%A3%8E%E6%A0%BC%20%E7%BE%8E%E5%A5%B3&pn=0&ie=utf-8&oe=utf-8&cl=2&lm=-1&fr=ala&se=&sme=")
print GetImg(htmltex)
- Python学习笔记:Python网络爬虫,实现爬取网络图片
- python网络爬虫爬取图片代码
- 【Python网络爬虫学习01】爬取网络验证码
- 利用Python实现网络爬取图片
- python网络爬虫学习笔记
- Python--网络爬虫学习笔记
- python网络爬虫学习笔记
- Python可自动登录爬取图片的网络爬虫
- Python网络爬虫requests、bs4爬取空姐网图片
- Python——网络爬虫(爬取网页图片)
- [笔记]python网络爬虫:一个简单的爬取图片并存储示例
- python网络爬虫学习(六)利用Pyspider+Phantomjs爬取淘宝模特图片
- Python爬取网络图片
- python爬虫实现网络股票信息爬取的demo
- [Python]网络爬虫学习笔记,爬取东南大学SEU-wlan的流量使用情况
- [Python]网络爬虫学习笔记,爬取豆瓣妹子上妹子的照片
- Python网络爬虫笔记
- Python爬虫学习笔记(1):简单的图片爬取
- ORA-29275: partial multibyte character
- oj 结尾0的个数
- oracle知识点(一)
- 梯度、散度、旋度、拉普拉斯算子、高斯散度定理
- 安卓学习笔记(2)- SQLite中使用query函数对某类数据进行排序
- Python学习笔记:Python网络爬虫,实现爬取网络图片
- 微信端开发配置
- 心急的C小家
- VC6在64位Win7下调试无法退出
- DelayQueue 实现延时消息队列实践
- 什么影响了数据库性能
- SQL Server如何导入超大的.sql文件
- 使用Python爬取中国大学排名,并格式化对其输出内容
- 关于kettle加载job找不到转换文件路径的问题解决