首页 > Web开发 > 详细

抓取网页链接,并保存到本地

时间:2015-01-12 14:31:51      阅读:291      评论:0      收藏:0      [点我收藏+]
import urllib2
import urllib

content=urllib2.urlopen("http://www.cnblogs.com/sayary/archive/2013/03/11/2952638.html").read()
##print content

##<a title="发布于2013-03-10 13:53"
##href="http://www.cnblogs.com/sayary/archive/2013/03/10/2952640.html">


href=content.find(rhref="http://www.cnblogs.com/sayary/archive)
end=content.find(r.html)
print href
print end

url=content[href+6:end+5]
print url




str2=content.find(rhref="http://www.cnblogs.com/sayary/archive,end)
end2=content.find(r.html,str2)

print str2
print end2

url2=content[str2+6:end2+5]

print url2
urllib.urlretrieve(url, 1.html)
urllib.urlretrieve(url2, 2.html)

 

 

抓取网页链接,并保存到本地

原文:http://www.cnblogs.com/xinshijie/p/4218232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!