首页 > Web开发 > 详细

爬虫,抓取网页图片

时间:2015-04-07 13:24:54      阅读:227      评论:0      收藏:0      [点我收藏+]
 1 #!usr/bin/env python
 2 #-*- coding:utf-8 -*-
 3 import urllib
 4 import re
 5 
 6 def getHtml(url):
 7     page = urllib.urlopen(url)
 8     html = page.read()
 9     return html
10     
11 def getImg(html):
12     reg = rsrc="http://.+\.jpg" class="img_pic_layer"
13     imgre = re.compile(reg)
14     imglist = imgre.findall(html)
15     return imglist[0][5:-23]
16     
17 html = getHtml("http://image.baidu.com/")
18 print getImg(html)

 

爬虫,抓取网页图片

原文:http://www.cnblogs.com/caixiaohong/p/4397856.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!