• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python爬虫入门教程之点点美女图片爬虫代码分享

python爬虫入门教程之点点美女图片爬虫代码分享

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了python爬虫入门,python爬虫入门教程,python爬虫入门书籍,python3爬虫入门教程,python3爬虫入门等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

继续鼓捣爬虫,今天贴出一个代码,爬取点点网「美女」标签下的图片,原图。

# -*- coding: utf-8 -*- 

#--------------------------------------- 
#  程序:点点美女图片爬虫 
#  版本:0.2 
#  作者:zippera 
#  日期:2013-07-26 
#  语言:Python 2.7 
#  说明:能设置下载的页数 
#--------------------------------------- 
 
import urllib2
import urllib
import re
 
 
 
pat = re.compile('<div class="feed-big-img">\n.*?imgsrc="(ht.*?)\".*?')
nexturl1 = "http://www.diandian.com/tag/%E7%BE%8E%E5%A5%B3?page="
 
 
count = 1
 
while count < 2:
 
  print "Page " + str(count) + "\n"
  myurl = nexturl1 + str(count)
  myres = urllib2.urlopen(myurl)
  mypage = myres.read()
  ucpage = mypage.decode("utf-8") #转码
 
  mat = pat.findall(ucpage)
  
 
  
  
  
  if len(mat):
    cnt = 1
    for item in mat:
      print "Page" + str(count) + " No." + str(cnt) + " url: " + item + "\n"
      cnt += 1
      fnp = re.compile('(\w{10}\.\w+)$')
      fnr = fnp.findall(item)
      if fnr:
        fname = fnr[0]
        urllib.urlretrieve(item, fname)
    
  else:
    print "no data"
    
  count += 1

</div>

使用方法:新建一个文件夹,把代码保存为name.py文件,运行python name.py就可以把图片下载到文件夹。

</div>

您可能想查找下面的文章:

  • python入门教程之识别验证码
  • Python爬虫代理IP池实现方法
  • Python爬虫代理IP池实现方法
  • Python入门教程之运算符与控制流
  • Python入门教程之运算符与控制流
  • 玩转python爬虫之爬取糗事百科段子
  • 玩转python爬虫之爬取糗事百科段子
  • Python制作爬虫采集小说
  • python制作花瓣网美女图片爬虫
  • python制作最美应用的爬虫

相关文章

  • Python中threading模块join函数用法实例分析
  • python访问抓取网页常用命令总结
  • Python open读写文件实现脚本
  • Python切片用法实例教程
  • 在Python中使用Mako模版库的简单教程
  • Go语言基于Socket编写服务器端与客户端通信的实例
  • python数据清洗系列之字符串处理详解
  • python计数排序和基数排序算法实例
  • Python中的choice()方法使用详解
  • python实现TCP服务器端与客户端的方法详解

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 基于Python的接口测试框架实例
    • PyMongo安装使用笔记
    • 关于Python元祖,列表,字典,集合的比较
    • Python实现竖排打印传单手机号码易撕条
    • Python正则表达式如何进行字符串替换实例
    • Python中文分词实现方法(安装pymmseg)
    • python实现调用其他python脚本的方法
    • 巧用Python装饰器 免去调用父类构造函数的麻烦
    • python使用多线程不断刷新网页的方法
    • Python常用列表数据结构小结

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有