#coding=utf-8
import urllib
import re def getHtml(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)

python常用代码的更多相关文章

  1. 【转载】GitHub 标星 1.2w+,超全 Python 常用代码合集,值得收藏!

    本文转自逆袭的二胖,作者二胖 今天给大家介绍一个由一个国外小哥用好几年时间维护的 Python 代码合集.简单来说就是,这个程序员小哥在几年前开始保存自己写过的 Python 代码,同时把一些自己比较 ...

  2. python 常用代码

    获取标签名 h1 class 是h1usersoup.find(name="h1", attrs={"class":"h1user"});获 ...

  3. python常用代码片段

    目录 Python3常用 文件处理 json处理 log日志 argparse使用 INIparser Python3常用 文件处理 class BaseMethod: @staticmethod d ...

  4. python常用代码积累

    一.文件操作 1.判断一个目录是否存在,若不存在则创建 if not os.path.isdir(new_path): os.makedirs(new_path) 2.新建一个文件 f=open(&q ...

  5. python常用代码、问题汇总

    1.生成dataframe数据 5.读取带 ','分隔符的txt文件 4.DataFrame格式数据处理中报错 2.安装库时出现如下错误: 3.得到股票交易日数据 1.生成dataframe数据 im ...

  6. Python 常用 代码片段

    文件名字中含有特殊字符转成空格,因为?‘’等作为文件名是非法的.以下正则表达式进行过滤转换 newname = re.sub("[\s+\.\!\/_,$%^*(+\"\')]+| ...

  7. Python常用代码,置顶备用!

    1.jupyter notebook 设置全部行输出: # 设置全部行输出 from IPython.core.interactiveshell import InteractiveShellInte ...

  8. Python常用代码2

    用matplotlib画图时,若设置全部行输出,会得到包括图标在内的所有输出结果. plt.show() 输出全部行,参数为“all”:输出最后一行,参数为“last_expr”

  9. [python] 常用正则表达式爬取网页信息及分析HTML标签总结【转】

    [python] 常用正则表达式爬取网页信息及分析HTML标签总结 转http://blog.csdn.net/Eastmount/article/details/51082253 标签: pytho ...

随机推荐

  1. socket,TCP/IP的理解

    TCP/IP 要想理解socket首先得熟悉一下TCP/IP协议族, TCP/IP(Transmission Control Protocol/Internet Protocol)即传输控制协议/网间 ...

  2. 0(Mark)(随时添加) ubuntu的一些 终端 命令整理

    MARK 1 查看cpu信息cat /proc/cpiinfo 2 查看ubuntu版本:cat /etc/issue 3 查看系统是32位还是64位方法1:#查看long的位数,返回32或64 ge ...

  3. 卡尔曼滤波— Constant Velocity Model

    假设你开车进入隧道,GPS信号丢失,现在我们要确定汽车在隧道内的位置.汽车的绝对速度可以通过车轮转速计算得到,汽车朝向可以通过yaw rate sensor(A yaw-rate sensor is ...

  4. lncRNA研究

    ------------------------------- Long noncoding RNAs are rarely translated in two human cell lines. ( ...

  5. weblogic解密工具

    import org.bouncycastle.jce.provider.BouncyCastleProvider; import sun.misc.BASE64Decoder; import jav ...

  6. div相对浏览器移动

    <%    String path = request.getContextPath();%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...

  7. Installing Python 3.5.2 from source

    Here are the procedures we are to follow, Download the source code of an official Python release. Co ...

  8. 问题处理:找不到Pch预编译文件?

    提醒:Xcode6之后就不再自动创建Pch预编译文件 在Xcode6之前,创建一个新工程xcode会在Supporting files文件夹下面自动创建一个“工程名-Prefix.pch”文件,也是一 ...

  9. 详解C#委托,事件与回调函数

    .Net编程中最经常用的元素,事件必然是其中之一.无论在ASP.NET还是WINFrom开发中,窗体加载(Load),绘制(Paint),初始化(Init)等等.“protected void Pag ...

  10. SQL Povit

    ),) ,,@logistics_code='All',@fee_type='All' ),) ,@strDateList='',@from_date=cast((ltrim(@yr)+'-'+ltr ...