简单入门爬斗鱼颜值区妹子照片 v1.1
2024-10-07 12:13:37
这是个比较简单的入门爬虫。基于python3。
urllib,urllib2,python3中用urllib.request代替,使用方法基本一致。
#python3
import urllib.request
import time
import re
import random
def getHtml(url):
#添加User_agent,头信息,伪装成浏览器请求。
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}
req = urllib.request.Request(url=url, headers=headers)
page = urllib.request.urlopen(req)
html = page.read()
return html def getImage(html):
html = html.decode('utf-8')
imageList = re.findall(r'src="(.*?\.(jpg|png))"',html)
x = 1
for imageUrl in imageList:
urllib.request.urlretrieve(imageUrl[0],'/home/hang/pythonLearning/Crawler/CrawlDouyuGirl/%d.%s'%(x,imageUrl[1]))
print("已下载:%s" % imageUrl[0])
x += 1
temp = random.randint(3,7)
time.sleep(temp) html = getHtml("https://www.douyu.com/directory/game/yz") getImage(html)
入门娱乐用,没太多技术含量,莫嘲笑。
最新文章
- linux 防火墙配置
- SSH三大框架合辑的搭建步骤
- Android的进程和线程(转)
- BZOJ 1833 ZJOI2010 count 数字计数 数位DP
- python初探-数据类型
- Google Code Jam Round 1C 2015 Problem A. Brattleship
- js加强版图片轮播
- iOS tableViewCell 在自定义高度方法中遇到的问题,cell高度为0,cell显示不出来,cell直接显示第几个而不是...cell显示个数不对
- POJ2398【判断点在直线哪一侧+二分查找区间】
- AJAX发送PUT请求引发的血案
- 关系数据库数据与hadoop数据进行转换的工具 - Sqoop
- webpack项目打包配置
- java基础要点总结
- spring cloud实战与思考(一) spring config全局配置方案设计
- scrapy xpath、正则表达式、css选择器
- Android Monkey压力测试环境搭建及使用
- LeetCode--155--最小栈(java版)
- 2019.3.22 Week 11 : ZigBee power test and field test
- HTML5纯Web前端也能开发直播,不用开发服务器(使用face2face)
- [hdu3685]Rotational Painting 凸包 重心
热门文章
- HDU 1880 题解(字符串哈希)
- mysql自动备份脚本
- Oracle DBA_EXTENTS视图 与 DBA_SEGMENTS视图
- controller函数中参数列表使用多个@RequestBody
- Tomcat 8.5 apr 模式配置
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency
- nativescript(angular2)——ListView组件
- jsp基础模板
- win7系统安装sql2000数据库时没有反应,不出来安装界面?
- gawk进阶