8000 GitHub - jinixin/CSDNSpider: Crawling the read number of every blog in CSDN everyday. · GitHub
[go: up one dir, main page]

Skip to content

About

Crawling the read number of every blog in CSDN everyday.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

Repository files navigation

CSDNSpider

Crawling the read number of every blog in CSDN everyday.

目的

  • 每天自动记录某用户的每篇CSDN博客访问量

  • 提供博客备份功能,把博客的文字信息备份到数据库

  • 博客数据可视化

    • 最近十天博客的日访问量
    • 博客每篇文章最近十天的访问增量
    • 当前博客每篇文章的访问量
  • 通过网络随时随地获取博客的访问情况

安装

  • 通过pip install -r requirements安装所需包

  • export CSDN_URL=某用户CSDN博客地址(如:http://blog.csdn.net/jinixin )
    export DB_USER=数据库用户
    export DB_PWD=数据库密码
    通过上面三条语句分别将待爬取地址,数据库信息写入环境;或者在脚本中直接替换,通过命令行参数将待爬取地址传入

  • 创建“blog_csdn”数据库后,向MySQL导入“blog_csdn.sql”文件

运行

记录访问量

  • 通过crontab -e设置Linux定时任务
    1 0 * * * nohup /绝对路径/crawler/blogPageViews.py 2>>/绝对路径/blogPageViews.log &
    (这样该脚本会在每天的00:01自动运行,注意修改具体路径)

  • 若不设置定时任务,也可每天在命令行键入“./blogPageViews.py”

备份博客

  • 这个不需要每天都运行,需要时命令行键入“./blogBackup.py”即可

可视化数据

  • 通过crontab -e设置Linux定时任务
    5 0 * * * nohup /绝对路径/analyse/blogImages.py 2>>/绝对路径/blogImages.log &
    (这样该脚本会在每天的00:05自动运行,注意修改具体路径)

  • 若不设置定时任务,也可每天在命令行键入“./blogImages.py”

  • Mac用户运行时若报错,请参考该链接;图片中文乱码,请参考该链接

  • 效果图

最近十天博客的日访问量

博客每篇文章的访问量

运行服务器

技术

  • Python语言,Flask框架

  • MySQL提供数据存储

  • Requests模块获取网页,BeautifulSoup与re模块提取目标元素

  • Matplotlib用于绘图,数据可视化

未来

  • 博客中的图片没能备份,以后图片也要备份

  • 继续丰富图表类型

  • 提供部署脚本,实现快速部署

About

Crawling the read number of every blog in CSDN everyday.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0