时间:2015-06-08 08:52 来源: 我爱IT技术网 作者:52ij
python 做网络爬虫下载数据
#!usr/bin/python
import re
import urllib
def getHtml(url):
page=urllib.urlopen(url)
html=page.read()
return html
def getImg(html):
reg=r'(http://cache.+)" alt'
imgre=re.compile(reg)
imglist=re.findall(imgre,html)
x=10
for imgurl in imglist:
trimurl=imgurl.replace("amp;","")
urllib.urlretrieve(trimurl, '%s.jpg' % x)
x=x+1
print trimurl
html=getHtml("网址")
getImg(html)- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
