一个简单的python网络爬虫程序(下载博客文章)
2014-11-03 19:27
471 查看
import urllib import time url = ['']*50 con = urllib.urlopen('http://blog.sina.com.cn/s/articlelist_1197161814_0_1.html').read() i = 0 title = con.find(r'<a title') href = con.find(r'href=',title) html = con.find(r'.html',href) while title!=-1 and href!=-1 and html!=-1 and i<50: url[i] = con[href + 6:html+5] print(url[i]) title = con.find(r'<a title=',html) href = con.find(r'href=',title) html = con.find(r'.html',href) i=i+1 else: print('find end!') j=0 while j<50: content = urllib.urlopen(url[j]).read() print('downloading......'+str(j+1)) open(r'likaifu/'+url[j][-26:],'w+').write(content) j=j+1 time.sleep(15) else: print('download title')
相关文章推荐
- Hello Python!用python写一个抓取CSDN博客文章的简单爬虫
- python下载QQ空间的博客文章
- 【python】爬虫1——下载博客文章
- Python爬虫——下载韩寒博客文章
- python3.6+BeautifulSoup4.6 爬取个人博客文章简单案例
- [Python下载CSDN博客]1. 简单实现(一)
- Python写的一个简单的下载程序
- Python项目实战之下载博客文章
- python_爬取博客文章下载到本地
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- [Python下载CSDN博客]1. 简单实现(三)
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- 用Python实现一个简单的能够上传下载的HTTP服务器
- 一个最简单的博客园文章密码暴力破解器-python3实现
- [Python学习] 简单网络爬虫抓取博客文章及思想介绍
- Python网络爬虫实训:如何下载韩寒博客文章
- 一个下载pdf的简单python爬虫
- CSDN博客专栏文章批量下载脚本[python实现]
- python基础学习——利用Flask实现一个简单博客
- Python学习笔记23:Django构建一个简单的博客网站(一个)