简单的python网络爬虫实现
来源:互联网 发布:js 换行符 编辑:程序博客网 时间:2024/06/05 17:01
此次爬虫很简单,就是爬斗鱼直播平台上的美女主播的图片 ,注要用了urllib2库,爬虫的网址是https://www.douyu.com/directory/game/yz 。直接贴代码:
import urllib2import urllibimport reimport timedef getHtml(url): request = urllib2.Request(url) request.add_header('User-Agent','Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36') response = urllib2.urlopen(request) html=response.read() return html
def getImage(html):
imglist=re.findall(r’data-original=”(.*?.(jpg|jpeg))”’,html)
print(len(imglist))
path =””
x=0
for img in imglist:
urllib.urlretrieve(img[0],”/home/qiracle/douyu/”+str(x)+”.”+img[1])
x+=1
time.sleep(1)
html =getHtml("https://www.douyu.com/directory/game/yz")getImage(html)
最终爬到的结果如下:
阅读全文
0 0
- 简单的网络爬虫的python实现
- 简单的python网络爬虫实现
- Python实现简单的网络爬虫
- python 实现简单网络爬虫
- python实现简单网络爬虫
- [python]简单的网络爬虫
- 网络爬虫的简单实现
- Python实现简单网络爬虫功能
- Python实现简单的爬虫
- Python实现简单的爬虫
- Python实现简单的爬虫
- Python简单爬虫的实现
- Python与简单网络爬虫的编写
- Python与简单网络爬虫的编写
- 简单的Python网络爬虫程序
- Python 网络爬虫--简单的模拟登录
- python网络爬虫的简单架构
- 网络爬虫(三) Java实现简单的网络爬虫
- Non-boring sequences UVA
- B
- socket网络编程(一):最简单的一收一发
- 采购单(京东2017秋招真题)
- react-native坑
- 简单的python网络爬虫实现
- Python-用__slots__限制类属性
- 初学oracle 数据库的初级运用 单表查询的各种基础方法(SQL)
- 20170817 JAVA DATE类用法整理
- bootstrap
- 求能被7整除且至少有一位数字为3的三位数
- Vm虚拟机中ubuntu无法上网
- 游戏中点击事件的冲突处理
- c语言的冒泡排序简单实例