爬虫之下载博客目录文章
2014-09-23 21:18
239 查看
根据源代码获得每条博客的链接地址,
#!/usr/bin/env python #codiing:utf-8 import time import urllib import webbrowser as web urlstr = "http://blog.sina.com.cn/s/articlelist_1191258123_0_1.html" #目录地址 content = urllib.urlopen(urlstr).read() #得到地址的源代码 title = content.find(r'<a title=', 0) #找到链接地址 href = content.find(r'href', title) html = content.find(r'.html', href) i = 0 url = ['']*40; while title != -1 and href != -1 and html != -1 and i < 40: #得到所有的链接地址 url[i] = content[href + 6: html + 5] title = content.find(r'<a title=',html) href = content.find(r'href', title) html = content.find(r'.html',href) i = i + 1 i = 1 for g in url: con = urllib.urlopen(g).read() #读取链接地址的源码 open(r'/home/yuan/pyth/' + str(i) + '.html', 'w+').write(con) #源码内容写入到本地上 time.sleep(15) i = i + 1
相关文章推荐
- Python爬虫——下载韩寒博客文章
- 【python】爬虫1——下载博客文章
- 【python】爬虫2——下载亦舒博客首页所有文章
- Python网络爬虫实训:如何下载韩寒博客文章
- 博客文章目录整理
- CSDN博客专栏文章批量下载脚本[python实现]
- SQL Sever 博客文章目录(2014-07-29更新)
- [推荐推荐][提供下载]ORACLE SQL:经典查询练手系列文章收尾(目录篇)
- 分享制作精良的知识管理系统 配置SQL Server文档数据库 完美实现博客文章的的下载,存储和浏览
- 陈硕博客文章合集下载(2013-02-01更新)
- 公告:CSDN博客频道推出文章目录功能
- 老徐的博客:文章目录
- 本博客文章的目录列表(手工不断整理...)【永久置顶】
- 下载博客文章并自动转换成pdf保存到本地
- Ruby:多线程队列(Queue)下载博客文章到本地
- ORACLE 博客文章目录(2014-08-07更新)
- 利用CyberArticle定时自动下载保存博客的新文章
- 博客目录——文章索引
- [推荐推荐][提供下载]ORACLE SQL:经典查询练手系列文章收尾(目录篇)
- 我的CSDN博客下载器,下载博客文章保存为mht文件