Python实现简单的网络爬虫
来源:互联网 发布:黑麒麟cms解压密码 编辑:程序博客网 时间:2024/06/05 04:52
#coding=utf-8import urllibimport redef getHtml(url): page = urllib.urlopen(url) html = page.read() return htmldef getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0 for imgurl in imglist: urllib.urlretrieve(imgurl,'%s.jpg' % x) x+=1html = getHtml("http://tieba.baidu.com/p/2460150866")print getImg(html)
re.compile() 可以把正则表达式编译成一个正则表达式对象.
re.findall() 方法读取html 中包含 imgre(正则表达式)的数据。
运行脚本将得到整个页面中包含图片的URL地址。
urllib.urlretrieve()方法,直接将远程数据下载到本地。阅读全文
0 0
- 简单的网络爬虫的python实现
- 简单的python网络爬虫实现
- Python实现简单的网络爬虫
- python 实现简单网络爬虫
- python实现简单网络爬虫
- [python]简单的网络爬虫
- 网络爬虫的简单实现
- Python实现简单网络爬虫功能
- Python实现简单的爬虫
- Python实现简单的爬虫
- Python实现简单的爬虫
- Python简单爬虫的实现
- Python与简单网络爬虫的编写
- Python与简单网络爬虫的编写
- 简单的Python网络爬虫程序
- Python 网络爬虫--简单的模拟登录
- python网络爬虫的简单架构
- 网络爬虫(三) Java实现简单的网络爬虫
- redis整合spring mybatis -- 缓存方案
- XcodeColors插件与CocoaLumberjack工具
- Eclipse项目转Android Studio详细步骤,保证管用!
- python创建excel
- Android Jni opencv中的重映射:remap()函数
- Python实现简单的网络爬虫
- 没有中断的距离传感器,打电话灭屏后无法使用PS亮屏
- 单元测试
- 【Scikit-Learn 中文文档】内核岭回归
- 电路实验
- npm 报错:npm ERR! missing script: start npm ERR! A complete log of this run can be found in: npm ERR!
- python爬虫urllib库学习(源码)
- Kotlin内联:noinline与crossinline
- 《硅谷传奇》