Python 爬虫简单实战之CSDN
来源:互联网 发布:java类的主方法是啥 编辑:程序博客网 时间:2024/06/07 07:59
此文仅是分享 <(o゜▽゜)o☆[BINGO!]
- 代码实现很简单,即用python爬虫不断请求文章页面即可.
- 主要用到requests库即可
- 别太过分了:-O
示例代码:
# -*- coding: utf-8 -*-# @Author : Sdite# @DateTime : 2017-07-16 14:17:22import requestsfrom bs4 import BeautifulSoupimport reimport timeheaders = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36',}# 准备阶段,获取博客内文章的链接,存放在变量url中url = "http://blog.csdn.net/vonsdite"res = requests.get(url=url, headers=headers)part = re.compile(r'<span class="link_title"><a href="(/vonsdite/article/details/.+?)"')url = part.findall(res.text)url = ['http://blog.csdn.net/' + tmp for tmp in url]# 刷阅读量阶段while True: for u in url: res = requests.get(url=u, headers=headers) text = res.text soup = BeautifulSoup(text, 'lxml') rank = soup.select('#blog_rank') part = re.compile(r'<li>(访问:)<span>(\d+次)</span></li>') rank = part.findall(str(rank[0])) rank = rank[0][0] + rank[0][1] print('博客: ' + rank) time.sleep(2)
阅读全文
1 0
- Python 爬虫简单实战之CSDN
- Python开发简单爬虫之实战演练
- python实战之网络爬虫
- Python爬虫实战之爬取链家广州房价_01简单的单页爬虫
- python开发简单爬虫:实战篇
- Python爬虫框架Scrapy实战之安装
- python爬虫实战之爬取知乎帖子
- Python爬虫实战之爬糗事百科
- python爬虫之模拟登陆csdn
- python爬虫之csdn刷博客访问量
- Python爬虫之模拟CSDN网站登录
- Python爬虫实战(三):简单爬取网页图片
- 简单爬虫实战
- Python+MongoDB 爬虫实战
- python爬虫实战
- Python爬虫实战
- python爬虫实战
- Python爬虫实战代码
- 【数据结构】拾遗(一):图的邻接矩阵创建以及其深广度遍历C++实现
- 垃圾回收的算法与实现 pdf
- Contains Duplicate II
- Java GC专家系列1:理解Java垃圾回收
- Android_Framework_WindowManagerService_总述
- Python 爬虫简单实战之CSDN
- Python初学笔记
- CDQ分治--模板 BZOJ 3262--陌上花开【三维偏序】
- bootstrap-markdown使用
- c#winform选择文件,文件夹,打开指定目录方法
- Android屏幕适配问题
- Android的数据存储之SharedPreference与文件File
- Array----- 120. Triangle(计算路径最小和)
- LeetCode 448. Find All Numbers Disappeared in an Array