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

时间:2015-05-17 18:28:38   收藏:0   阅读:149
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)   
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!