码迷,mamicode.com
首页 > 编程语言 > 详细

python写的的简单的爬虫小程序

时间:2015-05-17 18:28:38      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

import re 
import urllib
def getHtml(url):
    page=urllib.urlopen(url)
    html=page.read()
    return html
def getpic(html):
    s=r‘src="(.*?\.jpg)" pic_ext‘
    piclist=re.findall(s,html)
    x=0
    for imgurl in piclist:
        urllib.urlretrieve(imgurl,‘%d.jpg‘%x)
        x=x+1
html=getHtml(‘http://tieba.baidu.com/p/3216903619‘)
getpic(html)   

python写的的简单的爬虫小程序

标签:

原文地址:http://www.cnblogs.com/qiaozhoulin/p/4509949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!