【python】爬虫3——抓取亦舒博客所有文章
2014-07-22 16:43
891 查看
<span style="font-family: Arial, Helvetica, sans-serif;">#! /usr/bin/env python</span>
#coding=utf-8 from urllib import urlopen import time url = ['']*350 page = 1 link = 1#链接变量 while page<= 4: arti = urlopen('http://blog.sina.com.cn/s/articlelist_1227636382_0_'+str(page)+'.html').read() i = 0 title = arti.find(r'<a title=') href = arti.find(r'href=',title) html = arti.find(r'.html',href) while title != -1 and href != -1 and html != -1 and i<40: url[i] = arti[href+6:html+5] print link,' ',url[i] title = arti.find(r'<a title=',html) href = arti.find(r'href=',title) html = arti.find(r'.html',href) content = urlopen(url[i]).read() filename = url[i][-26:] print ' ',filename open(r'yishu/'+url[i][-26:],'w+').write(content) print 'downloading',url[i] i = i + 1 link = link+1#发现了多少链接地 time.sleep(1) else: print page,'find end' page=page+1 else: print'all find'
相关文章推荐
- 【python】爬虫2——下载亦舒博客首页所有文章
- python爬虫抓取51cto博客大牛的文章保存到MySQL数据库
- python爬虫抓取51cto博客大牛的文章保存到本地excel文件
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- python抓取月光博客的所有文章并且按照标题分词存入mongodb中
- [js高手之路]Node.js实现简易的爬虫-抓取博客所有文章列表信息
- Python爬虫小实践:爬取任意CSDN博客所有文章的文字内容(或可改写为保存其他的元素),间接增加博客访问量
- python爬虫之python2.7.8抓取csdn博客文章
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- Python爬虫小实践:爬取任意CSDN博客所有文章的文字内容(或可改写为保存其他的元素),间接增加博客访问量
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- Python 爬虫爬取指定博客的所有文章
- [js高手之路]Node.js实现简易的爬虫-抓取博客所有文章列表信息
- Hello Python!用python写一个抓取CSDN博客文章的简单爬虫
- Python 爬虫爬取指定博客的所有文章
- Python爬虫小实践:爬取任意CSDN博客所有文章的文字内容(或可改写为保存其他的元素),间接增加博客访问量
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- Python爬虫框架Scrapy 学习笔记 10.2 -------【实战】 抓取天猫某网店所有宝贝详情
- Python爬虫框架Scrapy 学习笔记 10.2 -------【实战】 抓取天猫某网店所有宝贝详情
- 用python实现的抓取腾讯视频所有电影的爬虫