Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

43.爬了知乎日报十多万条数据 #45

Open
ccforward opened this issue Oct 24, 2016 · 23 comments
Open

43.爬了知乎日报十多万条数据 #45

ccforward opened this issue Oct 24, 2016 · 23 comments
Assignees

Comments

@ccforward
Copy link
Owner

ccforward commented Oct 24, 2016

一个Node.js的知乎日报爬虫

爬取了从 20150519 以来所有的文章、点赞数、评论数和部分评论内容

感觉数据挺多,简单的统计了下,还挺有趣的。

具体的数据统计和分析移步到我在知乎上的回答

线上地址

技术栈

Node.js + Vue.js + MongoDB

  • Node.js做爬虫、express搭建web框架
  • MongoDB 存储所有爬取的历史数据和定时任务爬取的新数据
  • Vue2.0全家桶 + ES6 + stylus + webpack 做前端开发和构建
  • ES6 + echarts 做数据统计页面
  • 知乎的图片做了防盗链,部署了一个php服务来代理图片
  • 整个项目托管在了百度云-BAE上面

功能

爬虫任务

  1. 爬取所有历史记录,包括:文章标题、正文、评论、点赞相关的数据
  2. 每天 07:30 - 21:30 每两个小时爬取一次最新数据
  3. 每天 23:30 爬取当天的数据
  4. 每周三、日 00:30 更新前7天的评论点赞数

展示页面

  1. 统计入口页面

  2. 首页
    顶部是每天最新数据,点赞大于 1000 的做了高亮标红处理

    下面是历史每日数据

  3. 文章详情页 - 下面是2015年评论 TOP 1 的文章

  4. 文章的部分评论也爬了下来

    在页面最底部点开

  5. 按日期查看每日历史文章

    可以查看历史每一天的所有文章,主要用在统计页面上,后面做个日历入口方便跳转,链接如下:

    http://zhihu.ccforward.net/#/date?dtime=20161001

PS: 知乎日报第一篇文章

@golhoon
Copy link

golhoon commented Oct 27, 2016

太强了!!

@DanceSmile
Copy link

it is good !

@mariotong
Copy link

我很好奇的是这些api是怎么得到的

@ccforward
Copy link
Owner Author

@mariotong 用Charles抓包拿到的

@bestvist
Copy link

纯js实现吗

@ccforward
Copy link
Owner Author

ccforward commented Oct 30, 2016

@bestvist

99.9%是js
因为有一个代理图片(突破知乎图片的防盗链)的功能是我之前用PHP写的
以前放在了新浪的sae上,这次就没有重做,直接拿来用了

@eve0803
Copy link

eve0803 commented Dec 23, 2016

想知道楼主用了多长时间完成的

@ccforward
Copy link
Owner Author

@eve0803 业余时间偶尔做做 大块时间的话主要集中在两个周末里面

@golhoon
Copy link

golhoon commented Dec 27, 2016 via email

@mkgame2015
Copy link

真心厉害

@Huihuawk
Copy link

Huihuawk commented Jan 5, 2017

楼主真厉害!我得好好学习一下,争取在两三个月左右学习明白。学习过程中,有问题再来请教!

@ccforward
Copy link
Owner Author

@Huihuawk 十分乐意提供帮助 有什么问题直接问我就行

@mariotong
Copy link

安装的时候,会报一个关于node-gyp 的错,楼主知道是什么问题吗

@ccforward
Copy link
Owner Author

@mariotong 你试试先全局单独装一下 node-gyp

@eve0803
Copy link

eve0803 commented Apr 1, 2017

clone下来install后运行start报错Unhandled 'error' event 楼主知道怎么回事吗

@ccforward
Copy link
Owner Author

@eve0803 你在这 https://github.com/ccforward/zhihu/issues/new 开个issue
然后截图放上面我看下

@aiuluna
Copy link

aiuluna commented Apr 10, 2017

@eve0803 @ccforward Unhandled 'error' event 这个后来处理了吗?应该怎么弄?

@eve0803
Copy link

eve0803 commented Apr 11, 2017

@aiuluna 我当时解决是因为数据库密码用户名的问题,因为我没有设置用户名密码,注释掉页面就可以打开了,但是打开页面下方的数据会加载不出来看了是读取不到api,这个当时还没有找到原因。。。。

@yvonnegithub
Copy link

@ccforward 我install完了之后运行npm run start 报找不到config模块的错

@ccforward
Copy link
Owner Author

@yvonnegithub config.js.sample 重命名为 config.js

config.js 是配置文件 在里面配置你自己的信息

@yvonnegithub
Copy link

@ccforward 也出现了Unhandled 'error' event的错误,这个要怎么解决啊?

@ccforward
Copy link
Owner Author

@yvonnegithub 你在这 https://github.com/ccforward/zhihu/issues/new 开个issue 放上截图 我来看下

@gaowei1012
Copy link

学习了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests