pyton 爬虫-图片
来源:互联网 发布:杀破狼 js原版 编辑:程序博客网 时间:2024/05/24 06:23
emptyimport urllib.requestimport urllib.responseimport osimport rebaseDir = os.path.dirname(os.path.abspath(__file__))#os.path.abspath(__file__)当前绝对路径os.path.dirname(path) 返回path的目录imgDir = os.path.join(baseDir,"img")# os.path.join 将多个路径组合后返回url = "http://www.sccnn.com"user_agent = ''def getHtmlContent(url): page = urllib.request.Request(url) response = urllib.request.urlopen(page) content = response.read().decode("gbk") #print(content) return contentdef getImg(html): imglist = re.findall('src="(.+?\.jpg)', html)#正则匹配图片路径 i = 10 for imgurl in imglist:#遍历url #imghttplist = "https:%s" % imgurl imghttplist = "%s" % imgurl urllib.request.urlretrieve( imghttplist, '%s/%s.jpg'%(imgDir,i)) print("\033[32;1m -------第%s张----\033[0m"%i) i+=1htmlconent = getHtmlContent(url)getImg(htmlconent)
阅读全文
0 0
- pyton 爬虫-图片
- Pyton爬虫实现豆瓣登陆
- Pyton实现简单爬虫和正则表达式的利用
- 图片爬虫
- pyton random
- pyton: subprocess
- Pyton 线程
- pyton阶乘
- 爬虫(三)--图片爬虫
- 使用wxWidgets为[图片转ascii的Pyton程序]编写图形界面
- 爬虫抓取网页图片
- python多线程图片爬虫
- python爬虫抓取图片
- python实现图片爬虫
- python多线程图片爬虫
- python图片小爬虫
- 爬虫抓取网页图片
- python 爬虫 爬下图片
- 多版本(>30)并行控制的解决方案
- Perplexity(困惑度)
- openGL 透视校正插值
- AppScale3.01
- jQuery——eq()选择器
- pyton 爬虫-图片
- 欢迎使用CSDN-markdown编辑器
- Vue.js2.0 入门实例(三)(数据对接)
- rhcs+gfs2+corosync + pacemaker +postgres_streaming_replication
- /proc/meminfo分析(一)
- JAVA反射机制示例,读取excel数据映射到JAVA对象中
- 包含min函数的栈
- leetcode 147. Insertion Sort List 链表插入排序
- Linux的学习笔记06:批量创建用户的脚本