#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下爬某个网页的图片的更多相关文章

  1. python 爬虫得到网页的图片

    import urllib.request,os import re # 获取html 中的内容 def getHtml(url): page=urllib.request.urlopen(url) ...

  2. python抓取网页中图片并保存到本地

    #-*-coding:utf-8-*- import os import uuid import urllib2 import cookielib '''获取文件后缀名''' def get_file ...

  3. python抓取网页图片

    本人比较喜欢海贼王漫画,所以特意选择了网站http://www.mmonly.cc/ktmh/hzw/list_34_2.html来抓取海贼王的图片. 因为是刚刚学习python,代码写的不好,不要喷 ...

  4. python连续爬取多个网页的图片分别保存到不同的文件夹

      python连续爬取多个网页的图片分别保存到不同的文件夹 作者:vpoet mail:vpoet_sir@163.com #coding:utf-8 import urllib import ur ...

  5. python爬取某个网页的图片-如百度贴吧

    python爬取某个网页的图片-如百度贴吧 作者:vpoet mail:vpoet_sir@163.com 注:随意copy,不用告诉我 #coding:utf-8 import urllib imp ...

  6. 【Python全栈-CSS】CSS实现网页背景图片自适应全屏

    CSS实现网页背景图片自适应全屏 功能:实现能自适应屏幕大小又不会变形的背景大图,而且背景图片不会随着滚动条滚动而滚动. 以下是用CSS实现的方法: <html> <head> ...

  7. python3下爬取网页上的图片的爬虫程序

    import urllib.request import re #py抓取页面图片并保存到本地 #获取页面信息 def getHtml(url): html = urllib.request.urlo ...

  8. 使用python爬取P站图片

    刚开学时有一段时间周末没事,于是经常在P站的特辑里收图,但是P站加载图片的速度比较感人,觉得自己身为计算机专业,怎么可以做一张张图慢慢下这么low的事,而且这样效率的确也太低了,于是就想写个程序来帮我 ...

  9. 【Python开发】网页爬取心得

    转载:python 爬虫抓取心得分享 title:python 爬虫抓取心得分享 0x1.urllib.quote('要编码的字符串')如果你要在url请求里面放入中文,对相应的中文进行编码的话,可以 ...

随机推荐

  1. 改变进程的优先级,nice,getpriority,setpriority

    int getpriority(int which, int who);返回一组进程的优先级 参数which和who确定返回哪一组进程的优先级 The value which is one of PR ...

  2. 北邮新生排位赛2解题报告d-e

    <> 427. 学姐逗学弟 时间限制 3000 ms 内存限制 131072 KB 题目描述 学弟们来了之后,学姐每天都非常高兴的和学弟一起玩耍.这一天,学姐想出了这样一个游戏,她画了一棵 ...

  3. Solr安装入门

    Solr安装入门:http://www.importnew.com/12607.html 查询详解:http://www.360doc.com/content/14/0306/18/203871_35 ...

  4. java web中的多条件查询

    转自:http://blog.csdn.net/xulu_258/article/details/46623317 所谓多条件查询即为用户输入想要查询的条件,然后根据用户输入的条件进行查询. 当用户有 ...

  5. grafana+influxdb安装

    登录http://192.168.1.114:3000/login 2.修改完密码之后,进入主界面

  6. Final阶段第1周/共1周 Scrum立会报告+燃尽图 02

    作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2481] 版本控制:https://git.coding.net/liuyy08 ...

  7. np.stack() 与 tf.stack() 的简单理解

    说明:np ----> numpy       tf ----> tensorflownp.stack(arrays, axis=0) np.stack(arrays, axis=0) - ...

  8. Mat类型at问题-opencv-bug调试

    前言 调试程序的过程中,opencv创建矩阵之后对其赋值出现错误: Mat m = Mat::zeros(1, featureLen, CV_32FC1); Mat data = Mat::zeros ...

  9. 20155201 2016-2017-2 《Java程序设计》第七周学习总结

    20155201 2016-2017-2 <Java程序设计>第七周学习总结 教材学习内容总结 第十二章 Lambda Lamdba表达式 例如 Comparator<String& ...

  10. ThinkPHP3.2.3整合smarty模板(三)

    在smarty模板中使用thinkphp框架的U方法时要主要的问题: 1.不能直接使用{:U('Index/index')}: 2.正确的使用方法为:<!--{U("Login/log ...