{"id":13509080,"url":"https://github.com/ccforward/zhihu","last_synced_at":"2025-04-06T20:11:16.560Z","repository":{"id":29519945,"uuid":"33058425","full_name":"ccforward/zhihu","owner":"ccforward","description":"✨  zhihu daily Node.js、Vue.js ... ","archived":false,"fork":false,"pushed_at":"2017-07-22T09:56:58.000Z","size":2177,"stargazers_count":413,"open_issues_count":1,"forks_count":98,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-03-30T18:10:16.919Z","etag":null,"topics":["node-vue","nodejs","spider","vue","vue2-vuex-webpack","zhihu-daily"],"latest_commit_sha":null,"homepage":"http://zhihu.ccforward.net","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccforward.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-29T02:25:01.000Z","updated_at":"2025-03-23T16:18:19.000Z","dependencies_parsed_at":"2022-08-19T17:40:58.590Z","dependency_job_id":null,"html_url":"https://github.com/ccforward/zhihu","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fzhihu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fzhihu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fzhihu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccforward%2Fzhihu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccforward","download_url":"https://codeload.github.com/ccforward/zhihu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543591,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-vue","nodejs","spider","vue","vue2-vuex-webpack","zhihu-daily"],"created_at":"2024-08-01T02:01:02.688Z","updated_at":"2025-04-06T20:11:16.542Z","avatar_url":"https://github.com/ccforward.png","language":"JavaScript","readme":"# 知乎日报的 Spider-Man\n\n[详细介绍](https://github.com/ccforward/cc/issues/45)\n\n## About\n\nNode.js + Vue.js + MongoDB 的知乎日报爬虫项目\n\n## 技术栈\n\n#### 后端\n\nNode.js + Express + MongoDB\n\n使用 Express 搭建 web 服务，爬虫爬取的数据用 MongoDB 存储。\n\n\n用 node-jieba分词 分析正文的tag，做则更能准确的数据分析和内容搜索 (doing)\n\n#### 前端\n\nES6 + Vue + Webpack\n\n基于 Vue2.0 的单页面应用 用webpack做前端代码构建\n\n数据统计的页面使用原生 ES6 代码编写，单独配置了webpack做构建，没有和 Vue 的webpack构建代码混在一起\n\n## 使用说明\n\n### mongoDB\n\n1. 启动 mongoDB `sudo mongod`\n\n2. 用命令 `mongo`  进入命令行模式\n\n3. 创建数据库\n\n```shell\nuse zhihu\n```\n\n4. 创建用户 (这里的 username 和 password 要和 config.js 里相对应)\n\n```shell\ndb.createUser({\n  user: \"username\",\n  pwd: \"password\",\n  \"roles\" : [\n  {\n    \"role\" : \"readWrite\",\n    \"db\" : \"report\"\n  },{\n    \"role\" : \"dbAdmin\",\n    \"db\" : \"report\"\n  }]\n})\n```\n\n### 配置文件 config.js\n\nconfig.js.sample 重命名为 config.js\n\n说明:\n\n* auth 知乎日报用来验证用户的key 用于http的请求头(真正的key叫做 `Authorization`)\n* `fire: true` 是否启动爬虫爬取历史信息\n* `openTask:true` 表示开启定时任务  每日爬虫和定时更新\n* interval 爬虫间隔时间\n* start end  爬历史数据的开始结束时间 为由近到远的日期（知乎日报生日: 20130519）  \n  start时间 比 end时间 晚\n\n在config.js文件中设置 `fire: true`  表示开启爬虫，对应的 start end \n\n\n\n### 其他\n\n如果在页面的HTTP的请求头里想加入 Authorization 和 referer 可以用这个 [chrome扩展](https://github.com/ccforward/C-Header)\n\n![](http://ww2.sinaimg.cn/large/7853084cjw1f6wvzw1utxj208w0bhjrp.jpg)\n\n## 知乎日报的API\n\n### 1、启动界面图像\n\n* URL `http://news-at.zhihu.com/api/4/start-image/1080*1776`\n* 图像分辨:\n\t* 320*432\n\t* 480*728\n\t* 720*1184\n\t* 1080*1776\n\n现在返回的图片应该都不再区分分辨率，都是同一尺寸了\n\t\n### 2、最新消息\n* URL `http://news-at.zhihu.com/api/4/news/latest`\n\n\n### 3、历史消息\n* URL `http://news.at.zhihu.com/api/4/news/before/20150101`\n* 请求 20150101 返回 2014年12月31日 的内容\n* 请求日期大于今日 返回今日的内容\n\n### 4、文章详情内容\n* URL `http://news-at.zhihu.com/api/4/news/4620055`\n* 参数： 最新消息和历史消息返回的字段: id\n* 返回信息：\n\t* body： HTML格式的详情文章\n\t* title：文只标题\n\t* image：文章顶部的大图\n\t* image-source：图片的版权信息\n* 特殊情况：\n\t* `http://news-at.zhihu.com/api/4/story/3942319`\n\t* 来自之乎日报站外的内容\n\t* 返回的字段 没有body、img、image-source等字段\n\t* share_url 字段会跳转到站外文章\n\n#### 4.1、文章详情的点赞数、长评论、短评论数量\n* URL `http://news-at.zhihu.com/api/4/story-extra/7033320`\n* 返回信息：\n\t* long_comments： 长评论\n\t* popularity：点赞数\n\t* short_comments：短评论数\n\t* comments：总评论数\n\n### 5、文章长评论\n* URL `http://news-at.zhihu.com/api/4/story/4628696/long-comments` \n* story后面即为文章的id\n\n### 6、文章短评论\n* URL `http://news-at.zhihu.com/api/4/story/4628696/short-comments` \n\n### 7、主题日报的列表\n* URL `http://news-at.zhihu.com/api/4/themes`\n\n### 8、主题日报内容\n* URL `http://news-at.zhihu.com/api/4/theme/2`\n\n\n\n\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccforward%2Fzhihu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccforward%2Fzhihu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccforward%2Fzhihu/lists"}