python下爬某个网页的图片
#coding=utf-8 import re
import urllib def getHtml(url): #获取url对应得源码
page = urllib.urlopen(url)
html = page.read()
return html def 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+=1 html = getHtml("http://tieba.baidu.com/p/2460150866") #将这个页面的图片都爬下来
#print getImg(html)
参考:http://www.cnblogs.com/fnng/p/3576154.html
python下爬某个网页的图片的更多相关文章
- python 爬虫得到网页的图片
import urllib.request,os import re # 获取html 中的内容 def getHtml(url): page=urllib.request.urlopen(url) ...
- python抓取网页中图片并保存到本地
#-*-coding:utf-8-*- import os import uuid import urllib2 import cookielib '''获取文件后缀名''' def get_file ...
- python抓取网页图片
本人比较喜欢海贼王漫画,所以特意选择了网站http://www.mmonly.cc/ktmh/hzw/list_34_2.html来抓取海贼王的图片. 因为是刚刚学习python,代码写的不好,不要喷 ...
- python连续爬取多个网页的图片分别保存到不同的文件夹
python连续爬取多个网页的图片分别保存到不同的文件夹 作者:vpoet mail:vpoet_sir@163.com #coding:utf-8 import urllib import ur ...
- python爬取某个网页的图片-如百度贴吧
python爬取某个网页的图片-如百度贴吧 作者:vpoet mail:vpoet_sir@163.com 注:随意copy,不用告诉我 #coding:utf-8 import urllib imp ...
- 【Python全栈-CSS】CSS实现网页背景图片自适应全屏
CSS实现网页背景图片自适应全屏 功能:实现能自适应屏幕大小又不会变形的背景大图,而且背景图片不会随着滚动条滚动而滚动. 以下是用CSS实现的方法: <html> <head> ...
- python3下爬取网页上的图片的爬虫程序
import urllib.request import re #py抓取页面图片并保存到本地 #获取页面信息 def getHtml(url): html = urllib.request.urlo ...
- 使用python爬取P站图片
刚开学时有一段时间周末没事,于是经常在P站的特辑里收图,但是P站加载图片的速度比较感人,觉得自己身为计算机专业,怎么可以做一张张图慢慢下这么low的事,而且这样效率的确也太低了,于是就想写个程序来帮我 ...
- 【Python开发】网页爬取心得
转载:python 爬虫抓取心得分享 title:python 爬虫抓取心得分享 0x1.urllib.quote('要编码的字符串')如果你要在url请求里面放入中文,对相应的中文进行编码的话,可以 ...
随机推荐
- 一篇来自网络的关于“enqueue”events的简短参考(转)
仅供自己和各位同学参考: Enqueue Type Description enq: AD - allocate AU Synchronizes accesses to a specific OSM ...
- POJ 2513 字典树+并查集+欧拉路径
Description: 给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相接的一边必须是相同颜色的. 解题思路: 可以用图论中欧拉路的知识来解这道题,首先可以把木 ...
- 在mvc中弹出提示框
在传统的WebForm中,我们要弹出一个alert提示框非常简单,只要在页面中输出alert即可,比如输出: Response.Write("<script >alrer('我是 ...
- 在主Android Activity中加载Fragment的一般简易方法 ,来模拟一个微信界面。
在Fragment的生命周期中,需要重点关注onCreate.onCreateView.onViewCreated.Activity与Fragment生命周期在设计模式上大体一致. package c ...
- Solr安装入门
Solr安装入门:http://www.importnew.com/12607.html 查询详解:http://www.360doc.com/content/14/0306/18/203871_35 ...
- L237
The British parliament on Tuesday rejected overwhelmingly the Brexit deal, further complicating the ...
- json数组和json字符串转换成map解析
package demo; import java.util.List;import java.util.Map;import java.util.Map.Entry; import net.sf.j ...
- tp 缓存,前台提速
- ssh key建立后不能clone问题
在建立了ssh密钥对之后,要将私钥添加,公钥key添加到gitlab的ssh keys里. 添加成功后,这个时候,你可以clone了! 总结:如果是遇到重复输入密码的情况,可能是ssh-key,的私钥 ...
- LUN挂载到Linux主机后,如何对磁盘进行分区
将阵列上的LUN挂载到Linux主机后,如何对磁盘进行分区,方法参考https://www.ibm.com/developerworks/cn/linux/l-lpic1-v3-104-1/ fdis ...