用python爬博客
来源:互联网 发布:快站域名怎么填 编辑:程序博客网 时间:2024/05/13 13:46
用python爬博客
by 伍雪颖
以爬王垠的博客为例:
import reimport urllib2def getHtmlCode(url):return urllib2.urlopen(url).read()def findTitleUrl(htmlString): regTitleUrl = re.compile("href=\"(.+?)\"") return regTitleUrl.findall(htmlString)def findTitleContent(htmlString):regTitleContent = re.compile("\">(.+?)</a>")return regTitleContent.findall(htmlString)htmlCode = getHtmlCode('http://www.yinwang.org/')titleContent = findTitleContent(htmlCode)titleUrl = findTitleUrl(htmlCode)for i in range(0, len(titleUrl)):print titleContent[i+3]print titleUrl[i+8]htmlPage = getHtmlCode(titleUrl[i+8])f = open("%s.html"%(titleContent[i+3]),'wb')f.write(htmlPage)f.close
0 0
- 用python爬博客
- Python爬取CSDN博客
- python scrapy 爬博客信息
- Python博客
- python爬虫爬取csdn博客专家所有博客内容
- python爬取oschina博客列表
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- 使用python爬取csdn博客访问量
- python爬取博客标题和访问量
- Python 爬取CSDN博客频道
- Python爬虫爬取博客访问量
- 使用python爬取csdn博客访问量
- python爬取csdn的博客内容
- python爬取自己博客访问量
- 用python模拟登陆到CSDN博客
- 用Python编写博客导出工具
- 第九周项目五——程序填充题(3)
- Android的Activity, Intent 和 Service
- R:常用的向量运算
- 聚类算法(一)层次聚类
- js常用字符串方法
- 用python爬博客
- jquery取<input>的readOnly属性,O要大写(动态设置readonly属性无效)
- Leetcode--Path Sum
- 类的初始化学习
- Volley简介(四)
- 使用uploadify进行上传
- Drozer – Android APP安全评估工具小测
- ZOJ 3823Excavator Contest 构造 2014牡丹江现场赛E
- 学习较底层编程:动手写一个C语言编译器