码迷,mamicode.com
首页 > Web开发 > 详细

爬虫,抓取网页图片

时间:2015-04-07 13:25:57      阅读:145      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!