本人比较喜欢海贼王漫画,所以特意选择了网站http://www.mmonly.cc/ktmh/hzw/list_34_2.html来抓取海贼王的图片。

因为是刚刚学习python,代码写的不好,不要喷。

功能主要抓取此网页的图片如下:

贴代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import re
url1 = "http://www.mmonly.cc/ktmh/hzw/list_34_2.html"
request = urllib2.Request(url1)
req = urllib2.urlopen(request)
buf = req.read()
url_list = re.findall(r'src=\"http://t1.+?\.png', buf)#正则表达式
#for img_url in url_list:
# print img_url[5:] index = 1
for img_url in url_list:
f = open(str(index)+'.png','wb')
img_req = urllib2.urlopen(img_url[5:])
img_buf = img_req.read()
f.write(img_buf)
f.close()
index +=1

执行代码后的效果:

python抓取网页图片的更多相关文章

  1. python抓取网页图片的小案例

    1.分析 ,要抓取的页面的信息以及对应的源码信息 blog.sina.com.cn/s/blog 93dc666c0101b1bj.html 2.代码模块: 导入正则表达的模块 导入url相关的模块 ...

  2. Python 抓取网页并提取信息(程序详解)

    最近因项目需要用到python处理网页,因此学习相关知识.下面程序使用python抓取网页并提取信息,具体内容如下: #---------------------------------------- ...

  3. python抓取网页例子

    python抓取网页例子 最近在学习python,刚刚完成了一个网页抓取的例子,通过python抓取全世界所有的学校以及学院的数据,并存为xml文件.数据源是人人网. 因为刚学习python,写的代码 ...

  4. Python3简单爬虫抓取网页图片

    现在网上有很多python2写的爬虫抓取网页图片的实例,但不适用新手(新手都使用python3环境,不兼容python2), 所以我用Python3的语法写了一个简单抓取网页图片的实例,希望能够帮助到 ...

  5. 抓取网页图片的脚本(javascript)

    抓取网页图片的脚本(javascript) 本文地址: http://blog.csdn.net/caroline_wendy/article/details/24172223 脚本内容 (没有换行) ...

  6. Python抓取网页中的图片到本地

    今天在网上找了个从网页中通过图片URL,抓取图片并保存到本地的例子: #!/usr/bin/env python # -*- coding:utf- -*- # Author: xixihuang # ...

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

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

  8. 网络爬虫-使用Python抓取网页数据

    搬自大神boyXiong的干货! 闲来无事,看看了Python,发现这东西挺爽的,废话少说,就是干 准备搭建环境 因为是MAC电脑,所以自动安装了Python 2.7的版本 添加一个 库 Beauti ...

  9. C语言调用curl库抓取网页图片

    思路是先用curl抓取网页源码,然后以关键字寻找出图片网址.   #include <stdio.h> #include <stdlib.h> #include <str ...

随机推荐

  1. HDOJ(HDU) 2137 circumgyrate the string(此题用Java-AC不过!坑)

    此题如果有用JavaACDSee,请评论,谢谢了. Problem Description Give you a string, just circumgyrate. The number N mea ...

  2. poj1016

    题目大意:数据统计 看明白了,就是给你一个数,例如31123314,代表的意思有3个1,1个2,3个3,1个4,但数字本身的有的数字也是有3个1,1个2,3个3,1个4,所以这样的数叫做self-in ...

  3. Redis的安装及配置

    Redis安装及主从配置   一.何为Redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表) ...

  4. mysql数据类型介绍

    一.int.bigint.smallint 和 tinyint的区别详细介绍 bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854 ...

  5. CentOS 安装 Tomcat

    1.Tomcat官网获(http://tomcat.apache.org/)取tar.gz文件的下载地址 2.下载: # wget http://apache.fayea.com/tomcat/tom ...

  6. javascript 鼠標拖動功能

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. C++:类成员函数的重载、覆盖和隐藏区别?

    #include <iostream> class A { public: void func() { std::cout << "Hello" <& ...

  8. iOS iOS8新特性--UIPopoverPresentationController

    1.回顾UIPopoverController的使用,下面这份代码只能在ipad下运行 // 初始化控制器,SecondViewController类继承自UIViewController Secon ...

  9. Android 发送验证码 简易代码

    效果 Activity ;//倒计时 private Timer timer; private Handler handler = new Handler() { public void handle ...

  10. c - 计算1到20的阶乘

    #include <stdio.h> /* 题目:求 1+2!+3!+...+20!的和 */ unsigned long long int factorial(long n) { uns ...