您的位置:首页 > 编程语言 > Python开发

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

2015-05-17 16:33 211 查看
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'
reg=re.compile(s)                      #这句可有可无
piclist=re.findall(reg,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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: