feat: add prettier and commit hooks (#144)

* feat: add prettier and commit hooks

* style(*): prettier format

* fix(eslint): parsing error: Unexpected token ...

* style(eslint): eslint --fix

* style(bilibili): fix `no-undef` and `no-unused-vars`

* style(jiandan): fix eqeqeq

* style(pixiv): disable `no-constant-condition` rule for eslint

* fix(pixiv): use template string

* style(toutiao): remove unused variables

* style(weibo): use `forEach` instead of `map`

The array has no return value, you should use `forEach` instead of `map`

* chore(hooks): add eslint hooks

* chore(hooks): switch from husky to yorkie

* style(zhihu): prettier format

* style(docs): fix vuepress custom container

https://vuepress.vuejs.org/guide/markdown.html#custom-containers

* chore(prettier): set a more reasonable `printWidth` value

* style(*): better prettier format
This commit is contained in:
さくら
2018-05-17 10:52:29 +08:00
committed by DIYgod
parent f9888a6fb7
commit 49de384d2e
93 changed files with 1382 additions and 1132 deletions
+39
View File
@@ -0,0 +1,39 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# Use 4 spaces for the Python files
[*.py]
indent_size = 4
max_line_length = 80
# The JSON files contain newlines inconsistently
[*.json]
insert_final_newline = ignore
# Minified JavaScript files shouldn't be changed
[**.min.js]
indent_style = ignore
insert_final_newline = ignore
# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab
# Batch files use tabs for indentation
[*.bat]
indent_style = tab
[*.md]
trim_trailing_whitespace = false
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_size = 2
+8 -7
View File
@@ -1,8 +1,12 @@
{
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"env": {
"node": true,
@@ -10,7 +14,6 @@
},
"rules": {
"no-console": 0,
"no-extra-parens": 1,
"block-scoped-var": 1,
"curly": 1,
"eqeqeq": 1,
@@ -21,7 +24,6 @@
"comma-spacing": 1,
"comma-style": 1,
"func-call-spacing": 1,
"indent": 1,
"keyword-spacing": 1,
"linebreak-style": 1,
"lines-around-comment": 1,
@@ -32,14 +34,12 @@
"prefer-const": 1,
"no-unsafe-negation": 1,
"array-callback-return": 1,
"dot-location": 1,
"dot-notation": 1,
"no-eval": 1,
"no-extend-native": 1,
"no-extra-label": 1,
"semi": 1,
"space-before-blocks": 1,
"space-before-function-paren": 1,
"space-in-parens": 1,
"space-unary-ops": 1,
"spaced-comment": 1,
@@ -52,6 +52,7 @@
"rest-spread-spacing": 1,
"no-trailing-spaces": 1,
"quotes": [1, "single"],
"no-control-regex": 0
"no-control-regex": 0,
"prettier/prettier": 0
}
}
-3
View File
@@ -3,6 +3,3 @@ npm-debug.log
error.log
combined.log
.vscode
.prettierrc
.prettierignore
.editorconfig
+1
View File
@@ -0,0 +1 @@
package.json
+7
View File
@@ -0,0 +1,7 @@
{
"printWidth": 233,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
+96 -96
View File
@@ -13,90 +13,90 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
当前支持列表:
- bilibili
- 番剧
- UP 主投稿
- UP 主动态
- UP 主收藏夹
- UP 主投币视频
- UP 主粉丝
- UP 主关注用户
- 分区视频
- 视频评论
- link 公告
- 直播开播
- 直播搜索
- 直播分区
- 微博
- 博主
- 关键词
- 即刻
- 主题
- 用户动态
- 网易云音乐
- 歌单歌曲
- 用户歌单
- 歌手专辑
- 掘金
- 分类
- 简书
- 首页
- 7 日热门
- 30 日热门
- 专题
- 作者
- 知乎
- 收藏夹
- 用户动态
- 用户回答
- 专栏
- 知乎日报
- 自如
- 房源
- 快递
- 贴吧
- 帖子列表
- 妹子图
- 首页(最新)
- 分类
- 所有专题
- 专题详情
- 详情
- pixiv
- 用户收藏
- 用户动态
- 排行榜
- 豆瓣
- 正在上映的电影
- 正在上映的高分电影
- 即将上映的电影
- 北美票房榜
- 煎蛋
- 无聊图
- 喷嚏
- 图卦
- Dockone
- 周报
- 腾讯吐个槽
- 吐槽新帖
- 笔趣阁
- 小说章节
- 开发者头条
- 今天头条
- 独家号
- 极客时间
- 专栏文章
- 央视新闻
- 专题
- Disqus
- 评论
- Twitter
- 用户
- Instagram
- 用户
- Youtube
- 用户
- 频道
* bilibili
* 番剧
* UP 主投稿
* UP 主动态
* UP 主收藏夹
* UP 主投币视频
* UP 主粉丝
* UP 主关注用户
* 分区视频
* 视频评论
* link 公告
* 直播开播
* 直播搜索
* 直播分区
* 微博
* 博主
* 关键词
* 即刻
* 主题
* 用户动态
* 网易云音乐
* 歌单歌曲
* 用户歌单
* 歌手专辑
* 掘金
* 分类
* 简书
* 首页
* 7 日热门
* 30 日热门
* 专题
* 作者
* 知乎
* 收藏夹
* 用户动态
* 用户回答
* 专栏
* 知乎日报
* 自如
* 房源
* 快递
* 贴吧
* 帖子列表
* 妹子图
* 首页(最新)
* 分类
* 所有专题
* 专题详情
* 详情
* pixiv
* 用户收藏
* 用户动态
* 排行榜
* 豆瓣
* 正在上映的电影
* 正在上映的高分电影
* 即将上映的电影
* 北美票房榜
* 煎蛋
* 无聊图
* 喷嚏
* 图卦
* Dockone
* 周报
* 腾讯吐个槽
* 吐槽新帖
* 笔趣阁
* 小说章节
* 开发者头条
* 今天头条
* 独家号
* 极客时间
* 专栏文章
* 央视新闻
* 专题
* Disqus
* 评论
* Twitter
* 用户
* Instagram
* 用户
* Youtube
* 用户
* 频道
## 参与我们
@@ -104,15 +104,15 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
### 提交新的 RSS 内容
1. 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由
1. 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由
1. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本
1. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本
1. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md)
1. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md)
### 参与讨论
1. [Telegram 群](https://t.me/rsshub)
1. [Telegram 群](https://t.me/rsshub)
## 部署
@@ -128,24 +128,24 @@ RSSHub 是采用 MIT 许可的开源项目,使用完全免费。 但是随着
我们通过以下方式接受赞助:
- [微信支付](https://i.imgur.com/aq6PtWa.png)
- [支付宝](https://i.imgur.com/wv1Pj2k.png)
- [Paypal](https://www.paypal.me/DIYgod)
- 比特币: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
* [微信支付](https://i.imgur.com/aq6PtWa.png)
* [支付宝](https://i.imgur.com/wv1Pj2k.png)
* [Paypal](https://www.paypal.me/DIYgod)
* 比特币: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
### 周期性赞助
周期性赞助可以获得额外的回报,比如你的名字 会出现在 RSSHub 的 GitHub 仓库和现在我们的官网中。
- 通过 [OpenCollective](https://opencollective.com/RSSHub) 赞助成为 backer 或 sponsor
- 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助成为 backer
- 给我们发邮件联系赞助事宜: i#html.love
* 通过 [OpenCollective](https://opencollective.com/RSSHub) 赞助成为 backer 或 sponsor
* 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助成为 backer
* 给我们发邮件联系赞助事宜: i#html.love
## 鸣谢
### Sponsors
- [Sayori Studio](https://t.me/SayoriStudio)
* [Sayori Studio](https://t.me/SayoriStudio)
### Contributors
+36 -37
View File
@@ -1,39 +1,38 @@
{
"name": "RSSHub",
"description": "Connect the world with RSS",
"repository": "https://github.com/DIYgod/RSSHub",
"website": "https://rsshub.js.org/",
"logo": "https://i.imgur.com/NZpRScX.png",
"keywords": ["RSS"],
"env": {
"PORT": {
"value": "80",
"required": false
},
"PIXIV_USERNAME": {
"required": false
},
"PIXIV_PASSWORD": {
"required": false
},
"DISQUS_API_KEY": {
"required": false
},
"TWITTER_CONSUMER_KEY": {
"required": false
},
"TWITTER_CONSUMER_SECRET": {
"required": false
},
"TWITTER_ACCESS_TOKEN": {
"required": false
},
"TWITTER_ACCESS_TOKEN_SECRET": {
"required": false
},
"YOUTUBE_KEY": {
"required": false
}
}
"name": "RSSHub",
"description": "Connect the world with RSS",
"repository": "https://github.com/DIYgod/RSSHub",
"website": "https://rsshub.js.org/",
"logo": "https://i.imgur.com/NZpRScX.png",
"keywords": ["RSS"],
"env": {
"PORT": {
"value": "80",
"required": false
},
"PIXIV_USERNAME": {
"required": false
},
"PIXIV_PASSWORD": {
"required": false
},
"DISQUS_API_KEY": {
"required": false
},
"TWITTER_CONSUMER_KEY": {
"required": false
},
"TWITTER_CONSUMER_SECRET": {
"required": false
},
"TWITTER_ACCESS_TOKEN": {
"required": false
},
"TWITTER_ACCESS_TOKEN_SECRET": {
"required": false
},
"YOUTUBE_KEY": {
"required": false
}
}
}
+9 -8
View File
@@ -1,14 +1,15 @@
module.exports = {
port: process.env.PORT || 1200, // 监听端口
cacheType: process.env.CACHE_TYPE || 'memory', // 缓存类型,支持 'memory' 和 'redis',设为空可以禁止缓存
cacheExpire: process.env.CACHE_EXPIRE || 5 * 60, // 缓存时间,单位为秒
port: process.env.PORT || 1200, // 监听端口
cacheType: process.env.CACHE_TYPE || 'memory', // 缓存类型,支持 'memory' 和 'redis',设为空可以禁止缓存
cacheExpire: process.env.CACHE_EXPIRE || 5 * 60, // 缓存时间,单位为秒
ua: process.env.UA || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
listenInaddrAny: process.env.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1
listenInaddrAny: process.env.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1
redis: {
url: process.env.REDIS_URL || 'redis://localhost:6379/',
options: { // 支持这些参数 https://github.com/NodeRedis/node_redis#options-object-properties
options: {
// 支持这些参数 https://github.com/NodeRedis/node_redis#options-object-properties
password: process.env.REDIS_PASSWORD || null,
}
},
},
pixiv: {
client_id: 'MOBrBDS8blbauoSck0ZfDbtuzpyT',
@@ -26,6 +27,6 @@ module.exports = {
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
},
youtube: {
key: process.env.YOUTUBE_KEY
}
key: process.env.YOUTUBE_KEY,
},
};
+9 -8
View File
@@ -8,22 +8,23 @@ module.exports = {
editLinks: true,
editLinkText: '帮助我们改善此页面!',
docsDir: 'docs',
nav: [{
nav: [
{
text: '使用',
link: '/'
link: '/',
},
{
text: '参与我们',
link: '/joinus/'
link: '/joinus/',
},
{
text: '部署',
link: '/install/'
link: '/install/',
},
{
text: '支持 RSSHub',
link: '/support/'
link: '/support/',
},
]
}
}
],
},
};
+63 -53
View File
@@ -10,18 +10,20 @@ sidebar: auto
RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇怪怪的内容生成 RSS 订阅源
::: tip 提示
演示地址为 [rsshub.app](https://rsshub.app),缓存时间 10 分钟,可以随意使用
:::
## 内容过滤
可以使用以下 URL query 过滤出想要的内容,支持正则
- filter: 过滤标题和描述
* filter: 过滤标题和描述
- filter_title: 过滤标题
* filter_title: 过滤标题
- filter_description: 过滤描述
* filter_description: 过滤描述
举例: [https://rsshub.app/bilibili/user/coin/2267573?filter=微小微|赤九玖|暴走大事件](https://rsshub.app/bilibili/user/coin/2267573?filter=微小微|赤九玖|暴走大事件)
@@ -93,81 +95,81 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
动画
| MAD·AMV | MMD·3D | 短片·手书·配音 | 综合 |
| ------- | ------ | -------- | ---- |
| 24 | 25 | 47 | 27 |
| MAD·AMV | MMD·3D | 短片·手书·配音 | 综合 |
| ------- | ------ | -------------- | ---- |
| 24 | 25 | 47 | 27 |
番剧
| 连载动画 | 完结动画 | 资讯 | 官方延伸 |
| ---- | ---- | ---- | ---- |
| 33 | 32 | 51 | 152 |
| 连载动画 | 完结动画 | 资讯 | 官方延伸 |
| -------- | -------- | ---- | -------- |
| 33 | 32 | 51 | 152 |
国创
| 国产动画 | 国产原创相关 | 布袋戏 | 资讯 |
| ---- | ------ | ---- | ---- |
| 153 | 168 | 169 | 170 |
| 国产动画 | 国产原创相关 | 布袋戏 | 资讯 |
| -------- | ------------ | ------ | ---- |
| 153 | 168 | 169 | 170 |
音乐
| 原创音乐 | 翻唱 | VOCALOID·UTAU | 演奏 | 三次元音乐 | OP/ED/OST | 音乐选集 |
| ---- | ---- | ------------- | ---- | ----- | --------- | ---- |
| 28 | 31 | 30 | 59 | 29 | 54 | 130 |
| 原创音乐 | 翻唱 | VOCALOID·UTAU | 演奏 | 三次元音乐 | OP/ED/OST | 音乐选集 |
| -------- | ---- | ------------- | ---- | ---------- | --------- | -------- |
| 28 | 31 | 30 | 59 | 29 | 54 | 130 |
舞蹈
| 宅舞 | 三次元舞蹈 | 舞蹈教程 |
| ---- | ----- | ---- |
| 20 | 154 | 156 |
| 宅舞 | 三次元舞蹈 | 舞蹈教程 |
| ---- | ---------- | -------- |
| 20 | 154 | 156 |
游戏
| 单机游戏 | 电子竞技 | 手机游戏 | 网络游戏 | 桌游棋牌 | GMV | 音游 | Mugen |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ----- |
| 17 | 171 | 172 | 65 | 173 | 121 | 136 | 19 |
| 单机游戏 | 电子竞技 | 手机游戏 | 网络游戏 | 桌游棋牌 | GMV | 音游 | Mugen |
| -------- | -------- | -------- | -------- | -------- | --- | ---- | ----- |
| 17 | 171 | 172 | 65 | 173 | 121 | 136 | 19 |
科技
| 趣味科普人文 | 野生技术协会 | 演讲·公开课 | 星海 | 数码 | 机械 | 汽车 |
| ------ | ------ | ------ | ---- | ---- | ---- | ---- |
| 124 | 122 | 39 | 96 | 95 | 98 | 176 |
| 趣味科普人文 | 野生技术协会 | 演讲·公开课 | 星海 | 数码 | 机械 | 汽车 |
| ------------ | ------------ | ----------- | ---- | ---- | ---- | ---- |
| 124 | 122 | 39 | 96 | 95 | 98 | 176 |
生活
| 搞笑 | 日常 | 美食圈 | 动物圈 | 手工 | 绘画 | ASMR | 运动 | 其他 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 138 | 21 | 76 | 75 | 161 | 162 | 175 | 163 | 174 |
| 搞笑 | 日常 | 美食圈 | 动物圈 | 手工 | 绘画 | ASMR | 运动 | 其他 |
| ---- | ---- | ------ | ------ | ---- | ---- | ---- | ---- | ---- |
| 138 | 21 | 76 | 75 | 161 | 162 | 175 | 163 | 174 |
鬼畜
| 鬼畜调教 | 音MAD | 人力VOCALOID | 教程演示 |
| ---- | ---- | ---------- | ---- |
| 22 | 26 | 126 | 127 |
| 鬼畜调教 | 音 MAD | 人力 VOCALOID | 教程演示 |
| -------- | ------ | ------------- | -------- |
| 22 | 26 | 126 | 127 |
s
| 美妆 | 服饰 | 健身 | 资讯 |
| 美妆 | 服饰 | 健身 | 资讯 |
| ---- | ---- | ---- | ---- |
| 157 | 158 | 164 | 159 |
广告
| 广告 |
| 广告 |
| ---- |
| 166 |
娱乐
| 综艺 | 明星 | Korea相关 |
| ---- | ---- | ------- |
| 71 | 137 | 131 |
| 综艺 | 明星 | Korea 相关 |
| ---- | ---- | ---------- |
| 71 | 137 | 131 |
影视
| 影视杂谈 | 影视剪辑 | 短片 | 预告·资讯 | 特摄 |
| ---- | ---- | ---- | ----- | ---- |
| 182 | 183 | 85 | 184 | 86 |
| 影视杂谈 | 影视剪辑 | 短片 | 预告·资讯 | 特摄 |
| -------- | -------- | ---- | --------- | ---- |
| 182 | 183 | 85 | 184 | 86 |
### 视频评论
@@ -208,7 +210,9 @@ order: 排序方式,live_time 开播时间,online 人气
### 直播分区
::: warning 注意
由于接口未提供开播时间,如果直播间未更换标题与分区,将只会出现一次.如果直播间更换分区与标题,将再出现一次
:::
举例: [https://rsshub.app/bilibili/live/area/143/online](https://rsshub.app/bilibili/live/area/143/online)
@@ -217,7 +221,7 @@ order: 排序方式,live_time 开播时间,online 人气
参数
areaID: 分区ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询
areaID: 分区 ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询
order: 排序方式,live_time 开播时间,online 人气
@@ -232,7 +236,9 @@ order: 排序方式,live_time 开播时间,online 人气
参数: uid,用户 id,博主主页打开控制台执行 `/uid=(\d+)/. exec(document.querySelector('.opt_box .btn_bed').getAttribute('action-data'))[1]` 获取
::: warning 注意
上述方案获取 V+ 付费博主会有数据缺失,所以这里提供另外一种方式,这种方式的缺点是描述不如上面的完善,建议优先选择第一种方案
:::
举例: [https://rsshub.app/weibo/user2/3306934123](https://rsshub.app/weibo/user2/3306934123)
@@ -270,7 +276,9 @@ order: 排序方式,live_time 开播时间,online 人气
### 公众号
::: tip 提示
公众号抓取困难,目前可提供的方案是通过即刻的公众号主题订阅
:::
举例: [https://rsshub.app/jike/topic/584b8ac671a288001154a115](https://rsshub.app/jike/topic/584b8ac671a288001154a115)
@@ -311,9 +319,9 @@ order: 排序方式,live_time 开播时间,online 人气
参数: category,分类名
| 前端 | Android | iOS | 后端 | 设计 | 产品 | 工具资源 | 阅读 | 人工智能 |
| -------- | ------- | ---- | ------- | ------ | ------- | ------- | ------- | ---- |
| frontend | android | ios | backend | design | product | freebie | article | ai |
| 前端 | Android | iOS | 后端 | 设计 | 产品 | 工具资源 | 阅读 | 人工智能 |
| -------- | ------- | --- | ------- | ------ | ------- | -------- | ------- | -------- |
| frontend | android | ios | backend | design | product | freebie | article | ai |
## 简书
@@ -357,7 +365,6 @@ order: 排序方式,live_time 开播时间,online 人气
参数: id,作者 id,可在作者主页 URL 中找到
## 知乎
### 收藏夹
@@ -419,7 +426,9 @@ keyword: 关键词
## 快递
::: warning 注意
快递送达后请及时取消订阅,以免不必要地浪费服务器资源
:::
举例: [https://rsshub.app/express/youzhengguoji/CV054432809US](https://rsshub.app/express/youzhengguoji/CV054432809US)
@@ -445,7 +454,9 @@ number: 快递单号
## 妹子图
::: warning 注意
该网站在国外无法访问,故以下演示无效
:::
### 首页(最新)
@@ -462,10 +473,9 @@ number: 快递单号
参数:category,分类名
| 热门 | 推荐 | 性感妹子 | 日本妹子 | 台湾妹子 | 清纯妹子 |
| ---- | ---- | ------- | ----- | ------ | ---- |
| hot | best | xinggan | japan | taiwan | mm |
| 热门 | 推荐 | 性感妹子 | 日本妹子 | 台湾妹子 | 清纯妹子 |
| ---- | ---- | -------- | -------- | -------- | -------- |
| hot | best | xinggan | japan | taiwan | mm |
### 所有专题
@@ -517,13 +527,13 @@ number: 快递单号
mode: 排行榜类型
| pixiv 日排行 | pixiv 周排行 | pixiv 月排行 | pixiv 受男性欢迎排行 | pixiv 受女性欢迎排行 | pixiv 原创作品排行 | pixiv 新人排行 |
| --------- | --------- | --------- | ------------- | ------------- | ------------- | ----------- |
| day | week | month | day_male | day_female | week_original | week_rookie |
| pixiv 日排行 | pixiv 周排行 | pixiv 月排行 | pixiv 受男性欢迎排行 | pixiv 受女性欢迎排行 | pixiv 原创作品排行 | pixiv 新人排行 |
| ------------ | ------------ | ------------ | -------------------- | -------------------- | ------------------ | -------------- |
| day | week | month | day_male | day_female | week_original | week_rookie |
| pixiv R-18 日排行 | pixiv R-18 受男性欢迎排行 | pixiv R-18 受女性欢迎排行 | pixiv R-18 周排行 | pixiv R-18G 排行 |
| -------------- | ------------------ | ------------------ | -------------- | -------------- |
| day_r18 | day_male_r18 | day_female_r18 | week_r18 | week_r18g |
| ----------------- | ------------------------- | ------------------------- | ----------------- | ---------------- |
| day_r18 | day_male_r18 | day_female_r18 | week_r18 | week_r18g |
date: 日期,取值形如 `2018-4-25`
@@ -609,7 +619,7 @@ city: 城市的中文名,可选,默认北京
参数
project: 产品ID
project: 产品 ID
key: 产品密钥
+40 -28
View File
@@ -4,13 +4,13 @@ sidebar: auto
# 部署
部署 RSSHub 非常简单,如果您在部署过程中遇到无法解决的问题请到 [issues](https://github.com/DIYgod/RSSHub/issues) 寻找类似的问题或 [向我们提问](https://github.com/DIYgod/RSSHub/issues/new),我们会尽快给您答复。
部署 RSSHub 非常简单,如果您在部署过程中遇到无法解决的问题请到 [issues](https://github.com/DIYgod/RSSHub/issues) 寻找类似的问题或 [向我们提问](https://github.com/DIYgod/RSSHub/issues/new),我们会尽快给您答复。
[[toc]]
## 手动部署
部署 `RSSHub` 最直接的方式,您可以按照以下步骤将 `RSSHub` 部署在您的电脑、服务器或者其他任何地方。
部署 `RSSHub` 最直接的方式, 您可以按照以下步骤将 `RSSHub` 部署在您的  电脑、服务器或者其他任何地方。
### 在安装之前
@@ -19,37 +19,42 @@ sidebar: auto
### 安装 Git
::: tip 提示
首先您应该输入 `git`,看看系统有没有安装 Git
windows 打开 `cmd` macOS 打开`终端(terminal)`
``` bash
```bash
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
...
```
:::
* Windows:从Git官网直接[下载安装程序](https://git-scm.com/downloads)。
* MacOS:使用 [Homebrew](https://brew.sh/) `$ brew install git` 或者[下载安装程序](https://git-scm.com/download/mac)。
* Linux:使用您的包管理器安装例如 `$ sudo apt-get install git`。
* Windows:从 Git 官网直接[下载安装程序](https://git-scm.com/downloads)。
* MacOS:使用 [Homebrew](https://brew.sh/) `$ brew install git` 或者[下载安装程序](https://git-scm.com/download/mac)。
* Linux:使用您的包管理器安装例如 `$ sudo apt-get install git`
### 安装 Node.JS
#### Windows
Windows 用户请 [下载安装程序](https://nodejs.org/zh-cn/)。安装时,请勾选`Add to PATH`选项。
#### MacOS & Linux
安装 NodeJS 的最佳方式是使用 [nvm](https://github.com/creationix/nvm)。
安装 `nvm`
``` bash
```bash
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
```
安装完成后,重启终端并执行下列命令即可安装 `Node.js`
``` bash
```bash
$ nvm install node
```
@@ -57,33 +62,36 @@ $ nvm install node
首先是下载 `RSSHub` 的源码,请执行下列命令。
``` bash
```bash
$ git clone https://github.com/DIYgod/RSSHub.git
$ cd RSSHub
```
下载完成后,需要安装依赖。
``` bash
```bash
$ npm install
```
::: tip 提示
推荐使用 [Yarn](https://yarn.bootcss.com/) `Yarn``npm` 更快更稳定。
使用 `Yarn` 安装依赖时只需要键入
``` bash
```bash
$ yarn
```
由于众所周知的原因,在中国使用 `npm` 下载依赖十分缓慢,建议挂一个代理或者考虑使用 [NPM 镜像](https://npm.taobao.org/)。
:::
### 启动 RSSHub
`RSSHub` 文件夹中运行下面的命令就可以启动。
``` bash
```bash
$ npm start
```
@@ -110,7 +118,9 @@ macOS & Linux 运行 `$ PORT=1000`
RSSHub 默认会有 5 分钟的缓存,默认这个缓存是存放在内存中的。RSSHub 还支持 Redis 数据库缓存。
::: tip 提示
除非流量特别大或者您需要建立分布式集群,否则不需要 Redis 缓存。
:::
#### 安装 Redis
@@ -121,7 +131,7 @@ RSSHub 默认会有 5 分钟的缓存,默认这个缓存是存放在内存中
在安装目录中运行下面的命令启动 Redis。
``` bash
```bash
$ redis-server redis.windows.conf
```
@@ -129,13 +139,13 @@ $ redis-server redis.windows.conf
使用 [Homebrew](https://brew.sh/) 安装 Redis。
``` bash
```bash
$ brew install redis
```
再运行下面的命令启动 Redis。
``` bash
```bash
$ brew services start redis
```
@@ -143,7 +153,7 @@ $ brew services start redis
使用您的包管理器安装 Redis。
``` bash
```bash
# apt
$ sudo apt install redis-server
@@ -169,13 +179,13 @@ Docker 属于 Linux 容器的一种封装,提供简单易用的容器使用接
运行下面的命令下载 RSSHub 镜像。
``` bash
```bash
$ docker pull diygod/rsshub
```
然后运行 RSSHub 即可
``` bash
```bash
$ docker run -d --name rsshub -p 1200:1200 diygod/rsshub
```
@@ -183,7 +193,7 @@ $ docker run -d --name rsshub -p 1200:1200 diygod/rsshub
您可以使用下面的命令来关闭 RSSHub。
``` bash
```bash
$ docker stop rsshub
```
@@ -191,9 +201,9 @@ $ docker stop rsshub
配置运行在 docker 中的 RSSHub,最便利的方法是使用环境变量。
以设置缓存时间为1小时举例,只需要在运行时增加参数:`-e CACHE_EXPIRE=3600`
以设置缓存时间为 1 小时举例,只需要在运行时增加参数:`-e CACHE_EXPIRE=3600`
``` bash
```bash
$ docker run -d --name rsshub -p 1200:1200 -e CACHE_EXPIRE=3600 PORT=1000 diygod/rsshub
```
@@ -203,23 +213,23 @@ $ docker run -d --name rsshub -p 1200:1200 -e CACHE_EXPIRE=3600 PORT=1000 diygod
[docker-compose](https://docs.docker.com/compose/overview/) 是用来运行多容器 Docker 应用的小工具,可以简化配置部署过程:
1. 创建 volume 持久化 Redis 缓存
1. 创建 volume 持久化 Redis 缓存
``` bash
```bash
$ docker volume create redis-data
```
2. 修改 [docker-compose.yml](https://github.com/DIYgod/RSSHub/blob/master/docker-compose.yml) 中的 `environment` 进行配置
2. 修改 [docker-compose.yml](https://github.com/DIYgod/RSSHub/blob/master/docker-compose.yml) 中的 `environment` 进行配置
3. 部署
3. 部署
``` bash
```bash
$ docker-compose up
```
4. 更新
4. 更新
``` bash
```bash
$ docker-compose build
$ docker-compose up
```
@@ -235,7 +245,9 @@ $ docker-compose up
可以通过修改 `config.js` 或者设置环境变量来配置 RSSHub。
::: tip 提示
建议通过设置环境变量来配置 RSSHub。避免版本更新时的冲突。
:::
`PORT`: 监听端口,默认为 `1200`
+4 -4
View File
@@ -8,12 +8,12 @@ sidebar: auto
## 提交新的 RSS 内容
1. 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由
1. 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由
1. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本
1. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本
1. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md)
1. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md)
## 参与讨论
1. [Telegram 群](https://t.me/rsshub)
1. [Telegram 群](https://t.me/rsshub)
+8 -8
View File
@@ -12,24 +12,24 @@ RSSHub 是采用 MIT 许可的开源项目,使用完全免费。 但是随着
我们通过以下方式接受赞助:
- [微信支付](https://i.imgur.com/aq6PtWa.png)
- [支付宝](https://i.imgur.com/wv1Pj2k.png)
- [Paypal](https://www.paypal.me/DIYgod)
- 比特币: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
* [微信支付](https://i.imgur.com/aq6PtWa.png)
* [支付宝](https://i.imgur.com/wv1Pj2k.png)
* [Paypal](https://www.paypal.me/DIYgod)
* 比特币: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
## 周期性赞助
周期性赞助可以获得额外的回报,比如你的名字 会出现在 RSSHub 的 GitHub 仓库和现在我们的官网中。
- 通过 [OpenCollective](https://opencollective.com/RSSHub) 赞助成为 backer 或 sponsor
- 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助成为 backer
- 给我们发邮件联系赞助事宜: i#html.love
* 通过 [OpenCollective](https://opencollective.com/RSSHub) 赞助成为 backer 或 sponsor
* 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助成为 backer
* 给我们发邮件联系赞助事宜: i#html.love
## 鸣谢
### Sponsors
- [Sayori Studio](https://t.me/SayoriStudio)
* [Sayori Studio](https://t.me/SayoriStudio)
### Contributors
+1 -1
View File
@@ -59,7 +59,7 @@ if (config.cacheType === 'memory') {
},
onconnect: () => {
logger.info('Redis connect.');
}
},
})
);
}
+5 -3
View File
@@ -5,9 +5,11 @@ module.exports = async (ctx, next) => {
ctx.state.data.item = ctx.state.data.item.filter((item) => {
const title = item.title;
const description = item.description;
return !(ctx.query.filter && !title.match(ctx.query.filter) && !description.match(ctx.query.filter)
|| ctx.query.filter_title && !title.match(ctx.query.filter_title)
|| ctx.query.filter_description && !description.match(ctx.query.filter_description));
return !(
(ctx.query.filter && !title.match(ctx.query.filter) && !description.match(ctx.query.filter)) ||
(ctx.query.filter_title && !title.match(ctx.query.filter_title)) ||
(ctx.query.filter_description && !description.match(ctx.query.filter_description))
);
});
}
};
+1 -1
View File
@@ -11,4 +11,4 @@ module.exports = async (ctx, next) => {
};
ctx.set(headers);
await next();
};
};
+20 -14
View File
@@ -5,7 +5,7 @@ const readall = require('readall');
const crypto = require('crypto');
const lru = require('lru-cache');
module.exports = function (options = {}) {
module.exports = function(options = {}) {
const {
prefix = 'koa-cache:',
expire = 30 * 60, // 30 min
@@ -18,10 +18,10 @@ module.exports = function (options = {}) {
const memoryCache = lru({
maxAge: expire * 1000,
max: maxLength
max: maxLength,
});
return async function cache (ctx, next) {
return async function cache(ctx, next) {
const { url, path } = ctx.request;
const resolvedPrefix = typeof prefix === 'function' ? prefix.call(ctx, ctx) : prefix;
const key = resolvedPrefix + md5(ignoreQuery ? path : url);
@@ -50,7 +50,7 @@ module.exports = function (options = {}) {
}
}
if (!match || passParam && ctx.request.query[passParam]) {
if (!match || (passParam && ctx.request.query[passParam])) {
return await next();
}
@@ -69,14 +69,14 @@ module.exports = function (options = {}) {
try {
const trueExpire = routeExpire || expire;
await setCache(ctx, key, tkey, trueExpire);
} catch (e) { }
} catch (e) {} // eslint-disable-line no-empty
routeExpire = false;
};
/**
* getCache
*/
async function getCache (ctx, key, tkey) {
async function getCache(ctx, key, tkey) {
const value = memoryCache.get(key);
let type;
let ok = false;
@@ -85,7 +85,9 @@ module.exports = function (options = {}) {
ctx.response.status = 200;
type = memoryCache.get(tkey) || 'text/html';
// can happen if user specified return_buffers: true in redis options
if (Buffer.isBuffer(type)) {type = type.toString();}
if (Buffer.isBuffer(type)) {
type = type.toString();
}
ctx.response.set('X-Koa-Memory-Cache', 'true');
ctx.response.type = type;
try {
@@ -102,7 +104,7 @@ module.exports = function (options = {}) {
/**
* setCache
*/
async function setCache (ctx, key, tkey) {
async function setCache(ctx, key, tkey) {
ctx.state.data.lastBuildDate = new Date().toUTCString();
const body = JSON.stringify(ctx.state.data);
@@ -120,7 +122,7 @@ module.exports = function (options = {}) {
/**
* cacheType
*/
async function cacheType (ctx, tkey) {
async function cacheType(ctx, tkey) {
const type = ctx.response.type;
if (type) {
memoryCache.set(tkey, type);
@@ -128,7 +130,7 @@ module.exports = function (options = {}) {
}
};
function paired (route, path) {
function paired(route, path) {
const options = {
sensitive: true,
strict: true,
@@ -137,7 +139,8 @@ function paired (route, path) {
return pathToRegExp(route, [], options).exec(path);
}
function read (stream) {
// eslint-disable-next-line no-unused-vars
function read(stream) {
return new Promise((resolve, reject) => {
readall(stream, (err, data) => {
if (err) {
@@ -149,6 +152,9 @@ function read (stream) {
});
}
function md5 (str) {
return crypto.createHash('md5').update(str).digest('hex');
}
function md5(str) {
return crypto
.createHash('md5')
.update(str)
.digest('hex');
}
+1 -1
View File
@@ -11,4 +11,4 @@ module.exports = async (ctx, next) => {
ctx.body = 'RSSHub 发生了一些意外: ' + err;
ctx.status = 500;
}
};
};
+30 -29
View File
@@ -6,7 +6,7 @@ const readall = require('readall');
const crypto = require('crypto');
const Redis = require('redis');
module.exports = function (options = {}) {
module.exports = function(options = {}) {
let redisAvailable = false;
const {
@@ -17,20 +17,15 @@ module.exports = function (options = {}) {
passParam = '',
maxLength = Infinity,
ignoreQuery = false,
onerror = function () { },
onconnect = function () {},
onerror = function() {},
onconnect = function() {},
} = options;
const {
host:redisHost = 'localhost',
port:redisPort = 6379,
url:redisUrl = `redis://${redisHost}:${redisPort}/`,
options:redisOptions = {}
} = options.redis || {};
const { host: redisHost = 'localhost', port: redisPort = 6379, url: redisUrl = `redis://${redisHost}:${redisPort}/`, options: redisOptions = {} } = options.redis || {};
/**
* redisClient
*/
* redisClient
*/
const redisClient = wrapper(Redis.createClient(redisUrl, redisOptions));
redisClient.on('error', (error) => {
redisAvailable = false;
@@ -44,7 +39,7 @@ module.exports = function (options = {}) {
onconnect();
});
return async function cache (ctx, next) {
return async function cache(ctx, next) {
const { url, path } = ctx.request;
const resolvedPrefix = typeof prefix === 'function' ? prefix.call(ctx, ctx) : prefix;
const key = resolvedPrefix + md5(ignoreQuery ? path : url);
@@ -73,7 +68,7 @@ module.exports = function (options = {}) {
}
}
if (!redisAvailable || !match || passParam && ctx.request.query[passParam]) {
if (!redisAvailable || !match || (passParam && ctx.request.query[passParam])) {
return await next();
}
@@ -92,23 +87,25 @@ module.exports = function (options = {}) {
try {
const trueExpire = routeExpire || expire;
await setCache(ctx, key, tkey, trueExpire);
} catch (e) { }
} catch (e) {} // eslint-disable-line no-empty
routeExpire = false;
};
/**
* getCache
*/
async function getCache (ctx, key, tkey) {
* getCache
*/
async function getCache(ctx, key, tkey) {
const value = await redisClient.get(key);
let type;
let ok = false;
if (value) {
ctx.response.status = 200;
type = await redisClient.get(tkey) || 'text/html';
type = (await redisClient.get(tkey)) || 'text/html';
// can happen if user specified return_buffers: true in redis options
if (Buffer.isBuffer(type)) {type = type.toString();}
if (Buffer.isBuffer(type)) {
type = type.toString();
}
ctx.response.set('X-Koa-Redis-Cache', 'true');
ctx.response.type = type;
try {
@@ -123,9 +120,9 @@ module.exports = function (options = {}) {
}
/**
* setCache
*/
async function setCache (ctx, key, tkey, expire) {
* setCache
*/
async function setCache(ctx, key, tkey, expire) {
ctx.state.data.lastBuildDate = new Date().toUTCString();
const body = JSON.stringify(ctx.state.data);
@@ -141,9 +138,9 @@ module.exports = function (options = {}) {
}
/**
* cacheType
*/
async function cacheType (ctx, tkey, expire) {
* cacheType
*/
async function cacheType(ctx, tkey, expire) {
const type = ctx.response.type;
if (type) {
await redisClient.setex(tkey, expire, type);
@@ -151,7 +148,7 @@ module.exports = function (options = {}) {
}
};
function paired (route, path) {
function paired(route, path) {
const options = {
sensitive: true,
strict: true,
@@ -160,7 +157,8 @@ function paired (route, path) {
return pathToRegExp(route, [], options).exec(path);
}
function read (stream) {
// eslint-disable-next-line no-unused-vars
function read(stream) {
return new Promise((resolve, reject) => {
readall(stream, (err, data) => {
if (err) {
@@ -172,6 +170,9 @@ function read (stream) {
});
}
function md5 (str) {
return crypto.createHash('md5').update(str).digest('hex');
function md5(str) {
return crypto
.createHash('md5')
.update(str)
.digest('hex');
}
+1 -1
View File
@@ -11,4 +11,4 @@ module.exports = async (ctx, next) => {
...ctx.state.data,
});
}
};
};
+1 -1
View File
@@ -2,5 +2,5 @@
// https://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string/1497928#1497928
module.exports = async (ctx, next) => {
await next();
ctx.body = ctx.body?ctx.body.replace(/[\x00-\x1F\x7F]/g, ''):ctx.body;
ctx.body = ctx.body ? ctx.body.replace(/[\x00-\x1F\x7F]/g, '') : ctx.body;
};
+23 -4
View File
@@ -1,12 +1,26 @@
{
"name": "RSSHub",
"name": "rsshub",
"version": "0.0.1",
"description": "Make RSS Great Again!",
"main": "index.js",
"scripts": {
"start": "node index.js",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
"docs:build": "vuepress build docs",
"format": "prettier \"**/*.{js,json,md}\" --write"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
],
"*.{js,json,md}": [
"prettier --write",
"git add"
]
},
"repository": {
"type": "git",
@@ -22,7 +36,13 @@
},
"homepage": "https://github.com/DIYgod/RSSHub#readme",
"devDependencies": {
"vuepress": "0.8.4"
"eslint": "4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.0",
"lint-staged": "^7.1.0",
"prettier": "^1.12.1",
"vuepress": "0.8.4",
"yorkie": "^1.0.3"
},
"dependencies": {
"art-template": "4.12.2",
@@ -30,7 +50,6 @@
"cheerio": "1.0.0-rc.2",
"co-redis": "2.1.1",
"crypto": "1.0.1",
"eslint": "4.19.1",
"form-data": "^2.3.2",
"googleapis": "30.0.0",
"json-bigint": "0.2.3",
+11 -9
View File
@@ -1,11 +1,13 @@
{
"apps": [{
"name": "rsshub",
"script": "index.js",
"instances": "max",
"exec_mode": "cluster",
"env": {
"NODE_ENV": "production"
"apps": [
{
"name": "rsshub",
"script": "index.js",
"instances": "max",
"exec_mode": "cluster",
"env": {
"NODE_ENV": "production"
}
}
}]
}
]
}
+1 -1
View File
@@ -58,7 +58,7 @@ router.get('/zhihu/collection/:id', require('./routes/zhihu/collection'));
router.get('/zhihu/people/activities/:id', require('./routes/zhihu/activities'));
router.get('/zhihu/people/answers/:id', require('./routes/zhihu/answers'));
router.get('/zhihu/zhuanlan/:id', require('./routes/zhihu/zhuanlan'));
router.get('/zhihu/daily', require('./routes/zhihu/daily'))
router.get('/zhihu/daily', require('./routes/zhihu/daily'));
// 贴吧
router.get('/tieba/forum/:kw', require('./routes/tieba/forum'));
+11 -9
View File
@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: `https://bangumi.bilibili.com/jsonp/seasoninfo/${seasonid}.ver?callback=seasonListCallback&jsonp=jsonp&_=${+new Date()}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://bangumi.bilibili.com/anime/${seasonid}/`
}
Referer: `https://bangumi.bilibili.com/anime/${seasonid}/`,
},
});
const data = JSON.parse(response.data.match(/^seasonListCallback\((.*)\);$/)[1]).result || {};
@@ -19,11 +19,13 @@ module.exports = async (ctx) => {
title: data.title,
link: `https://bangumi.bilibili.com/anime/${seasonid}/`,
description: data.evaluate,
item: data.episodes && data.episodes.map((item) => ({
title: `${item.index}${item.index_title}`,
description: `更新时间:${item.update_time}<img referrerpolicy="no-referrer" src="${item.cover}">`,
pubDate: new Date(item.update_time).toUTCString(),
link: item.webplay_url
})),
item:
data.episodes &&
data.episodes.map((item) => ({
title: `${item.index}${item.index_title}`,
description: `更新时间:${item.update_time}<img referrerpolicy="no-referrer" src="${item.cover}">`,
pubDate: new Date(item.update_time).toUTCString(),
link: item.webplay_url,
})),
};
};
};
+13 -10
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
mid: uid
mid: uid,
}),
});
const name = nameResponse.data.data.name;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: `https://space.bilibili.com/ajax/member/getCoinVideos?mid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const data = response.data;
@@ -33,10 +33,13 @@ module.exports = async (ctx) => {
title: `${name} 的 bilibili 投币视频`,
link: `https://space.bilibili.com/${uid}`,
description: `${name} 的 bilibili 投币视频`,
item: data.data && data.data.list && data.data.list.map((item) => ({
title: item.title,
description: `${item.title}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
link: `https://www.bilibili.com/video/av${item.stat.aid}`
})),
item:
data.data &&
data.data.list &&
data.data.list.map((item) => ({
title: item.title,
description: `${item.title}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
link: `https://www.bilibili.com/video/av${item.stat.aid}`,
})),
};
};
};
+6 -8
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const data = response.data.data.cards;
@@ -38,11 +38,9 @@ module.exports = async (ctx) => {
let link = '';
if (data.dynamic_id) {
link = `https://t.bilibili.com/${data.dynamic_id}`;
}
else if (data.aid) {
} else if (data.aid) {
link = `https://www.bilibili.com/video/av${data.aid}`;
}
else if (data.id) {
} else if (data.id) {
link = `https://h.bilibili.com/${data.id}`;
}
@@ -50,8 +48,8 @@ module.exports = async (ctx) => {
title: data.title || data.description || data.content,
description: `${data.desc || data.description || data.content}${imgHTML}`,
pubDate: new Date((data.pubdate || data.upload_time || data.timestamp) * 1000).toUTCString(),
link: link
link: link,
};
}),
};
};
};
+15 -12
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
mid: uid
mid: uid,
}),
});
const name = nameResponse.data.data.name;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/v2/fav/video?vmid=${uid}&ps=30&tid=0&keyword=&pn=1&order=fav_time`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/#/favlist`
}
Referer: `https://space.bilibili.com/${uid}/#/favlist`,
},
});
const data = response.data;
@@ -33,12 +33,15 @@ module.exports = async (ctx) => {
title: `${name} 的 bilibili 收藏夹`,
link: `https://space.bilibili.com/${uid}/#/favlist`,
description: `${name} 的 bilibili 收藏夹`,
item: data.data && data.data.archives && data.data.archives.map((item) => ({
title: item.title,
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.fav_at * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`
})),
item:
data.data &&
data.data.archives &&
data.data.archives.map((item) => ({
title: item.title,
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.fav_at * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`,
})),
};
};
};
+8 -8
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
mid: uid
mid: uid,
}),
});
const name = nameResponse.data.data.name;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/relation/stat?vmid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const count = countResponse.data.data.follower;
@@ -34,8 +34,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/relation/followers?vmid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const data = response.data.data.list;
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
title: `${name} 新粉丝 ${item.uname}`,
description: `${item.uname}<br>${item.sign}<br>总计${count}`,
pubDate: new Date(item.mtime * 1000).toUTCString(),
link: `https://space.bilibili.com/${item.mid}`
link: `https://space.bilibili.com/${item.mid}`,
})),
};
};
};
+8 -8
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
mid: uid
mid: uid,
}),
});
const name = nameResponse.data.data.name;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/relation/stat?vmid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const count = countResponse.data.data.following;
@@ -34,8 +34,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/relation/followings?vmid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const data = response.data.data.list;
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
title: `${name} 新关注 ${item.uname}`,
description: `${item.uname}<br>${item.sign}<br>总计${count}`,
pubDate: new Date(item.mtime * 1000).toUTCString(),
link: `https://space.bilibili.com/${item.mid}`
link: `https://space.bilibili.com/${item.mid}`,
})),
};
};
};
+18 -17
View File
@@ -4,19 +4,18 @@ const config = require('../../config');
module.exports = async (ctx) => {
const product = ctx.params.product;
let productTitle = ``;
let productTitle = '';
switch (product) {
case "live":
productTitle = `直播`;
case 'live':
productTitle = '直播';
break;
case "vc":
productTitle = `小视频`;
case 'vc':
productTitle = '小视频';
break;
case "wh":
productTitle = `相簿`;
case 'wh':
productTitle = '相簿';
break;
}
const response = await axios({
@@ -24,8 +23,8 @@ module.exports = async (ctx) => {
url: `https://api.vc.bilibili.com/news/v1/notice/list?platform=pc&product=${product}&category=all&page_no=1&page_size=20`,
headers: {
'User-Agent': config.ua,
'Referer': `https://link.bilibili.com/p/eden/news`
}
Referer: 'https://link.bilibili.com/p/eden/news',
},
});
const data = response.data.data.items;
@@ -34,11 +33,13 @@ module.exports = async (ctx) => {
link: `https://link.bilibili.com/p/eden/news#/?tab=${product}&tag=all&page_no=1`,
description: `bilibili ${productTitle}公告`,
lastBuildDate: new Date().toUTCString(),
item: data && data.map((item) => ({
title: item.title,
description: `${item.mark}<br><img referrerpolicy="no-referrer" src="${item.cover_url}">`,
pubDate: new Date(item.ctime.replace(' ', 'T') + "+08:00").toUTCString(),
link: item.announce_link ? item.announce_link : `https://link.bilibili.com/p/eden/news#/newsdetail?id=${item.id}`
})),
item:
data &&
data.map((item) => ({
title: item.title,
description: `${item.mark}<br><img referrerpolicy="no-referrer" src="${item.cover_url}">`,
pubDate: new Date(item.ctime.replace(' ', 'T') + '+08:00').toUTCString(),
link: item.announce_link ? item.announce_link : `https://link.bilibili.com/p/eden/news#/newsdetail?id=${item.id}`,
})),
};
};
};
+20 -21
View File
@@ -5,38 +5,37 @@ module.exports = async (ctx) => {
const areaID = ctx.params.areaID;
const order = ctx.params.order;
let orderTitle = ``;
let orderTitle = '';
switch (order) {
case "live_time":
orderTitle = `最新开播`;
case 'live_time':
orderTitle = '最新开播';
break;
case "online":
orderTitle = `人气直播`;
case 'online':
orderTitle = '人气直播';
break;
}
const nameResponse = await axios({
method: 'get',
url: `https://api.live.bilibili.com/room/v1/Area/getList`,
url: 'https://api.live.bilibili.com/room/v1/Area/getList',
headers: {
'User-Agent': config.ua,
'Referer': `https://link.bilibili.com/p/center/index`
}
Referer: 'https://link.bilibili.com/p/center/index',
},
});
let parentTitle = "";
let parentID = "";
let areaTitle = "";
let areaLink = "";
let parentTitle = '';
let parentID = '';
let areaTitle = '';
let areaLink = '';
for (parentArea of nameResponse.data.data) {
for (area of parentArea.list) {
for (const parentArea of nameResponse.data.data) {
for (const area of parentArea.list) {
if (area.id === areaID) {
parentTitle = parentArea.name;
parentID = parentArea.id;
areaTitle = area.name;
cateID = area.cate_id;
// cateID = area.cate_id;
switch (parentID) {
case 1:
areaLink = `https://live.bilibili.com/pages/area/ent-all#${area.cate_id}/${areaID}`;
@@ -46,7 +45,7 @@ module.exports = async (ctx) => {
areaLink = `https://live.bilibili.com/p/eden/area-tags#/${parentID}/${areaID}`;
break;
case 4:
areaLink = "https://live.bilibili.com/pages/area/draw";
areaLink = 'https://live.bilibili.com/pages/area/draw';
break;
}
}
@@ -58,8 +57,8 @@ module.exports = async (ctx) => {
url: `https://api.live.bilibili.com/room/v1/area/getRoomList?area_id=${areaID}&sort_type=${order}&page_size=30&page_no=1`,
headers: {
'User-Agent': config.ua,
'Referer': `https://live.bilibili.com/p/eden/area-tags`
}
Referer: 'https://live.bilibili.com/p/eden/area-tags',
},
});
const data = response.data.data;
@@ -73,7 +72,7 @@ module.exports = async (ctx) => {
description: `${item.uname} ${item.title}`,
pubDate: new Date().toUTCString(),
guid: `https://live.bilibili.com/${item.roomid} ${item.title}`,
link: `https://live.bilibili.com/${item.roomid}`
link: `https://live.bilibili.com/${item.roomid}`,
})),
};
};
};
+12 -13
View File
@@ -4,16 +4,15 @@ const config = require('../../config');
module.exports = async (ctx) => {
let roomID = ctx.params.roomID;
//短号查询长号
// 短号查询长号
if (parseInt(roomID, 10) < 10000) {
const roomIDResponse = await axios({
method: 'get',
url: `https://api.live.bilibili.com/room/v1/Room/room_init?id=${roomID}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://live.bilibili.com/${roomID}`
}
Referer: `https://live.bilibili.com/${roomID}`,
},
});
roomID = roomIDResponse.data.data.room_id;
}
@@ -23,8 +22,8 @@ module.exports = async (ctx) => {
url: `https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${roomID}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://live.bilibili.com/${roomID}`
}
Referer: `https://live.bilibili.com/${roomID}`,
},
});
const name = nameResponse.data.data.info.uname;
@@ -34,20 +33,20 @@ module.exports = async (ctx) => {
url: `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomID}&from=room`,
headers: {
'User-Agent': config.ua,
'Referer': `https://live.bilibili.com/${roomID}`
}
Referer: `https://live.bilibili.com/${roomID}`,
},
});
const data = response.data.data;
let liveItem = [];
const liveItem = [];
if (data.live_status === 1) {
liveItem.push({
title: `${data.title} ${data.live_time}`,
description: `${ data.title}<br>${data.description}`,
pubDate: new Date(data.live_time.replace(' ', 'T') + "+08:00").toUTCString(),
description: `${data.title}<br>${data.description}`,
pubDate: new Date(data.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
guid: `https://live.bilibili.com/${roomID} ${data.live_time}`,
link: `https://live.bilibili.com/${roomID}`
link: `https://live.bilibili.com/${roomID}`,
});
}
@@ -58,4 +57,4 @@ module.exports = async (ctx) => {
lastBuildDate: new Date().toUTCString(),
item: liveItem,
};
};
};
+10 -12
View File
@@ -1,6 +1,4 @@
const axios = require('axios');
const art = require('art-template');
const path = require('path');
const config = require('../../config');
module.exports = async (ctx) => {
@@ -8,14 +6,14 @@ module.exports = async (ctx) => {
const order = ctx.params.order;
const urlEncodedKey = encodeURIComponent(key);
let orderTitle = ``;
let orderTitle = '';
switch (order) {
case "live_time":
orderTitle = `最新开播`;
case 'live_time':
orderTitle = '最新开播';
break;
case "online":
orderTitle = `人气直播`;
case 'online':
orderTitle = '人气直播';
break;
}
@@ -24,8 +22,8 @@ module.exports = async (ctx) => {
url: `https://search.bilibili.com/api/search?search_type=live_room&keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1`,
headers: {
'User-Agent': config.ua,
'Referer': `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`
}
Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
},
});
const data = response.data.result;
@@ -37,9 +35,9 @@ module.exports = async (ctx) => {
item: data.map((item) => ({
title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
pubDate: new Date(item.live_time.replace(' ', 'T') + "+08:00").toUTCString(),
pubDate: new Date(item.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
link: `https://live.bilibili.com/${item.roomid}`
link: `https://live.bilibili.com/${item.roomid}`,
})),
};
};
};
+11 -9
View File
@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: `https://api.bilibili.com/x/web-interface/newlist?ps=15&rid=${tid}&_=${+new Date()}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://www.bilibili.com/'
}
Referer: 'https://www.bilibili.com/',
},
});
const list = response.data.data.archives;
@@ -23,11 +23,13 @@ module.exports = async (ctx) => {
title: `bilibili ${name}分区`,
link: 'https://www.bilibili.com',
description: `bilibili ${name}分区`,
item: list && list.map((item) => ({
title: `${item.title} - ${item.owner.name}`,
description: `${item.desc}<img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.pubdate * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`
})),
item:
list &&
list.map((item) => ({
title: `${item.title} - ${item.owner.name}`,
description: `${item.desc}<img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.pubdate * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`,
})),
};
};
};
+7 -7
View File
@@ -12,20 +12,20 @@ module.exports = async (ctx) => {
headers: {
'User-Agent': config.ua,
},
responseType: 'arraybuffer'
responseType: 'arraybuffer',
});
const responseHtml = iconv.decode(nameResponse.data, 'UTF-8');
const $ = cheerio.load(responseHtml);
let name = $("title").text();
name = name.substr(0, name.indexOf("_哔哩哔哩"));
let name = $('title').text();
name = name.substr(0, name.indexOf('_哔哩哔哩'));
const response = await axios({
method: 'get',
url: `https://api.bilibili.com/x/v2/reply?type=1&oid=${aid}&sort=0`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.bilibili.com/video/av${aid}`,
}
Referer: `https://www.bilibili.com/video/av${aid}`,
},
});
const data = response.data.data.replies;
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
title: `${item.member.uname} : ${item.content.message}`,
description: `#${item.floor}<br> ${item.member.uname} : ${item.content.message}`,
pubDate: new Date(item.ctime * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${aid}/#reply${item.rpid}`
link: `https://www.bilibili.com/video/av${aid}/#reply${item.rpid}`,
})),
};
};
};
+14 -11
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://space.bilibili.com/ajax/member/GetInfo',
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`,
Referer: `https://space.bilibili.com/${uid}/`,
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
mid: uid
mid: uid,
}),
});
const name = nameResponse.data.data.name;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
url: `https://space.bilibili.com/ajax/member/getSubmitVideos?mid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://space.bilibili.com/${uid}/`
}
Referer: `https://space.bilibili.com/${uid}/`,
},
});
const data = response.data;
@@ -33,11 +33,14 @@ module.exports = async (ctx) => {
title: `${name} 的 bilibili 空间`,
link: `https://space.bilibili.com/${uid}`,
description: `${name} 的 bilibili 空间`,
item: data.data && data.data.vlist && data.data.vlist.map((item) => ({
title: item.title,
description: `${item.description}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.created * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`
})),
item:
data.data &&
data.data.vlist &&
data.data.vlist.map((item) => ({
title: item.title,
description: `${item.description}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.created * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`,
})),
};
};
};
+16 -8
View File
@@ -13,25 +13,33 @@ module.exports = async (ctx) => {
url: `${baseUrl}${id}/`,
headers: {
'User-Agent': config.ua,
'Host':'www.biquge5200.com',
'Referer': `${baseUrl}${id}/`
Host: 'www.biquge5200.com',
Referer: `${baseUrl}${id}/`,
},
// responseEncoding: 'gbk', //该配置项在 0.18版本中没有打包进去
responseType: 'arraybuffer'
responseType: 'arraybuffer',
});
const responseHtml = iconv.decode(response.data, 'GBK');
// console.log('responseHtml',responseHtml);
const $ = cheerio.load(responseHtml);
const title = $('#list>dl>dt>b').eq(0).text();
const description = $('#intro>p').eq(0).text();
const cover_url = $('#fmimg>img').eq(0).attr('src');
const title = $('#list>dl>dt>b')
.eq(0)
.text();
const description = $('#intro>p')
.eq(0)
.text();
const cover_url = $('#fmimg>img')
.eq(0)
.attr('src');
const list = $('dd', '#list>dl').slice(0, 9);
const chapter_item = [];
for (let i = 0; i < list.length; i++) {
const el = $(list[i]).find('a').eq(0);
const el = $(list[i])
.find('a')
.eq(0);
const item = {
title: el.text(),
link: el.attr('href')
link: el.attr('href'),
};
chapter_item.push(item);
}
+18 -16
View File
@@ -6,49 +6,51 @@ const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const listRes = await axios({
method: 'get',
url: `https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70`,
url: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
headers: {
'User-Agent': config.ua,
'Referer': `https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70`,
Referer: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
},
// 喷嚏网编码为GBK,需要转码
// 转码需要设定返回数据的格式,其可选项是arraybuffer,blob,document,json,text,stream
// 默认为json
responseType: 'arraybuffer'
responseType: 'arraybuffer',
});
// 转码
const data = iconv.decode(listRes.data, 'gb2312');
const $ = cheerio.load(data);
// 只取最近的三个图卦,取全文rss
const list = $('li','ul').slice(0,3);
let result_item = [];
//为了避免async/await嵌套,使用for循环代替map方法
for(let i=0;i<list.length;i++) {
const list = $('li', 'ul').slice(0, 3);
const result_item = [];
// 为了避免async/await嵌套,使用for循环代替map方法
for (let i = 0; i < list.length; i++) {
const el = $(list[i]);
const url = `https://www.dapenti.com/blog/${el.find('a').attr("href")}`;
const url = `https://www.dapenti.com/blog/${el.find('a').attr('href')}`;
const original_data = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
'Referer': url,
Referer: url,
},
responseType: 'arraybuffer'
responseType: 'arraybuffer',
});
const convert_data = iconv.decode(original_data.data, 'gbk');
const detail_data = cheerio.load(convert_data, {decodeEntities: false})('div[class="oblog_text"]');
const detail_data = cheerio.load(convert_data, {
decodeEntities: false,
})('div[class="oblog_text"]');
const item = {
title: el.text(),
description: detail_data,
link: url
link: url,
};
result_item.push(item)
result_item.push(item);
}
ctx.state.data = {
title: `喷嚏图卦`,
link: `https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70`,
description: `喷嚏图卦`,
title: '喷嚏图卦',
link: 'https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=70',
description: '喷嚏图卦',
item: result_item,
};
};
+6 -6
View File
@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: `https://disqus.com/api/3.0/forums/listPosts.json?api_key=${config.disqus.api_key}&forum=${forum}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://disqus.com/'
}
Referer: 'https://disqus.com/',
},
});
const data = response.data.response;
@@ -29,8 +29,8 @@ module.exports = async (ctx) => {
url: `https://disqus.com/api/3.0/forums/listThreads.json?api_key=${config.disqus.api_key}&forum=${forum}${threadsQuery}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://disqus.com/'
}
Referer: 'https://disqus.com/',
},
});
const threads = responseThreads.data.response;
@@ -45,8 +45,8 @@ module.exports = async (ctx) => {
title: `${item.author.name}: ${item.raw_message > 24 ? item.raw_message.slice(0, 24) + '...' : item.raw_message}`,
description: `${item.author.name} 在《${thread.clean_title}》中发表评论: ${item.message}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: `${thread.link}/#comment-${item.id}`
link: `${thread.link}/#comment-${item.id}`,
};
}),
};
};
};
+16 -13
View File
@@ -3,10 +3,10 @@ const cheerio = require('cheerio');
const config = require('../../config');
function replaceEmpty(str) {
return str.replace(' ','');
return str.replace(' ', '');
}
const baseUrl='http://weekly.dockone.io'
const baseUrl = 'http://weekly.dockone.io';
module.exports = async (ctx) => {
const url = `${baseUrl}/issues`;
@@ -16,26 +16,29 @@ module.exports = async (ctx) => {
url: url,
headers: {
'User-Agent': config.ua,
Referer: url
}
Referer: url,
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('ul.i.issues>li');
ctx.state.data = {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((item,index) => {
item=$(index);
return {
title:`${replaceEmpty(item.find('a>h3>time').text())}[${replaceEmpty(item.find('a>h3>strong').text())}]`,
description:item.find('a>ul>li').text(),
link:`${baseUrl}${item.find('a').attr('href')}`
};
}).get(),
item:
list &&
list
.map((item, index) => {
item = $(index);
return {
title: `${replaceEmpty(item.find('a>h3>time').text())}[${replaceEmpty(item.find('a>h3>strong').text())}]`,
description: item.find('a>ul>li').text(),
link: `${baseUrl}${item.find('a').attr('href')}`,
};
})
.get(),
};
};
+2 -2
View File
@@ -13,7 +13,7 @@ module.exports = async (ctx) => {
item: movieList.map((item) => ({
title: item.title,
description: `标题:${item.title}<br> 影片类型:${item.genres.join(' | ')} <br>评分:${item.rating.stars === '00' ? '无' : item.rating.average} <br/> <img referrerpolicy="no-referrer" src="${item.images.large}">`,
link: item.alt
link: item.alt,
})),
};
};
};
+3 -3
View File
@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://api.douban.com/v2/movie/in_theaters',
params: { city }
params: { city },
});
const movieList = score ? response.data.subjects.filter((item) => item.rating.average >= score) : response.data.subjects;
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
item: movieList.map((item) => ({
title: item.title,
description: `标题:${item.title}<br> 影片类型:${item.genres.join(' | ')} <br>评分:${item.rating.average} <br/> <img referrerpolicy="no-referrer" src="${item.images.large}">`,
link: item.alt
link: item.alt,
})),
};
};
};
+2 -2
View File
@@ -15,8 +15,8 @@ module.exports = async (ctx) => {
return {
title: item.title,
description: `标题:${item.title}<br> 影片类型:${item.genres.join(' | ')} <br>评分:${item.rating.stars === '00' ? '无' : item.rating.average} <br/> <img referrerpolicy="no-referrer" src="${item.images.large}">`,
link: item.alt
link: item.alt,
};
}),
};
};
};
+4 -4
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://www.kuaidi100.com/query?type=${company}&postid=${number}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://www.kuaidi100.com'
}
Referer: 'https://www.kuaidi100.com',
},
});
const data = response.data.data;
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
title: item.context,
description: item.context,
pubDate: new Date(item.time || item.ftime).toUTCString(),
link: item.context
link: item.context,
})),
};
};
};
+10 -10
View File
@@ -10,12 +10,12 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/intro',
headers: {
'User-Agent': config.ua,
'Referer': 'https://time.geekbang.org/',
'Content-Type': 'application/json'
Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
},
data: {
cid: column_id
}
cid: column_id,
},
});
const intro_data = intro_response.data.data;
@@ -26,12 +26,12 @@ module.exports = async (ctx) => {
url: 'https://time.geekbang.org/serv/v1/column/articles/latest',
headers: {
'User-Agent': config.ua,
'Referer': 'https://time.geekbang.org/',
'Content-Type': 'application/json'
Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
},
data: {
cid: column_id
}
cid: column_id,
},
});
const articles = latest_response.data.data.list;
@@ -44,7 +44,7 @@ module.exports = async (ctx) => {
title: item.article_title,
description: item.article_summary,
pubDate: new Date(item.article_ctime * 1000).toUTCString(),
link: `https://time.geekbang.org/column/article/${item.id}`
link: `https://time.geekbang.org/column/article/${item.id}`,
})),
};
};
};
+13 -13
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://www.instagram.com/${id}/`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.instagram.com/${id}/`
}
Referer: `https://www.instagram.com/${id}/`,
},
});
const data = JSON.parse(response.data.match(/<script type="text\/javascript">window._sharedData = (.*);<\/script>/)[1]) || {};
@@ -29,21 +29,21 @@ module.exports = async (ctx) => {
let type = '';
let tip = '';
switch (item.__typename) {
case 'GraphVideo':
type = '[视频] ';
tip = '打开原文播放视频: ';
break;
case 'GraphSidecar':
type = '[组图] ';
tip = '打开原文查看组图: ';
break;
case 'GraphVideo':
type = '[视频] ';
tip = '打开原文播放视频: ';
break;
case 'GraphSidecar':
type = '[组图] ';
tip = '打开原文查看组图: ';
break;
}
return {
title: `${type}${item.edge_media_to_caption.edges && item.edge_media_to_caption.edges[0] && item.edge_media_to_caption.edges[0].node.text || '无题'}`,
title: `${type}${(item.edge_media_to_caption.edges && item.edge_media_to_caption.edges[0] && item.edge_media_to_caption.edges[0].node.text) || '无题'}`,
description: `${tip}<img referrerpolicy="no-referrer" src="${item.thumbnail_src}">`,
pubDate: new Date(item.taken_at_timestamp * 1000).toUTCString(),
link: `https://www.instagram.com/p/${item.shortcode}/`
link: `https://www.instagram.com/p/${item.shortcode}/`,
};
}),
};
};
};
+27 -17
View File
@@ -3,7 +3,12 @@ const cheerio = require('cheerio');
const crypto = require('crypto');
const config = require('../../config');
const md5 = (i) => crypto.createHash('md5').update(i).digest().toString('hex');
const md5 = (i) =>
crypto
.createHash('md5')
.update(i)
.digest()
.toString('hex');
const base64_decode = (i) => new Buffer(i, 'base64').toString('binary');
@@ -20,8 +25,8 @@ const jandan_magic = async (url) => {
url: 'http:' + url,
headers: {
'User-Agent': config.ua,
'Referer': 'http://jandan.net'
}
Referer: 'http://jandan.net',
},
});
const regex = /e,"([a-zA-Z0-9]{32})"/;
return script.data.match(regex)[1];
@@ -29,12 +34,12 @@ const jandan_magic = async (url) => {
// jandan_decode is borrowed from jandan.net, which is used in function jandan_load_img.
const jandan_decode = (m, r) => {
let q = 4;
const q = 4;
r = md5(r);
let o = md5(r.substr(0, 16));
let n = md5(r.substr(16, 16));
let l = m.substr(0, q);
let c = o + md5(o + l);
const o = md5(r.substr(0, 16));
const n = md5(r.substr(16, 16));
const l = m.substr(0, q);
const c = o + md5(o + l);
let k;
m = m.substr(q);
k = base64_decode(m);
@@ -60,28 +65,27 @@ const jandan_decode = (m, r) => {
[h[p], h[f]] = [h[f], h[p]];
t += chr(ord(k[g]) ^ h[(h[p] + h[f]) % 256]);
}
if ((t.substr(0, 10) == 0 || t.substr(0, 10) - time() > 0) && t.substr(10, 16) == md5(t.substr(26) + n).substr(0, 16)) {
if ((t.substr(0, 10) === '0' || t.substr(0, 10) - time() > 0) && t.substr(10, 16) === md5(t.substr(26) + n).substr(0, 16)) {
t = t.substr(26);
}
return t;
};
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'http://jandan.net/pic',
headers: {
'User-Agent': config.ua,
'Referer': 'http://jandan.net'
}
Referer: 'http://jandan.net',
},
});
const $ = cheerio.load(response.data);
let script_url = '';
$('script').each((index, item) => {
let s = $(item).attr('src');
const s = $(item).attr('src');
if (s && s.startsWith('//cdn.jandan.net/static/min/')) {
script_url = s;
}
@@ -97,14 +101,20 @@ module.exports = async (ctx) => {
}
// Get current comment's link.
const link = $(item).find('.righttext').find('a').attr('href');
const link = $(item)
.find('.righttext')
.find('a')
.attr('href');
if (link === undefined) {
return;
}
// Get current comment's images.
// TODO: should support multiple images.
let img_url = $(item).find('.text').find('.img-hash').html();
let img_url = $(item)
.find('.text')
.find('.img-hash')
.html();
if (img_url === null) {
return;
}
@@ -116,7 +126,7 @@ module.exports = async (ctx) => {
items.push({
title: comment_id,
description: `<img referrerpolicy="no-referrer" src="http:${img_url}">`,
link: `http:${link}`
link: `http:${link}`,
});
});
@@ -124,6 +134,6 @@ module.exports = async (ctx) => {
title: '煎蛋无聊图',
link: 'http://jandan.net/pic',
description: '煎蛋官方无聊图,无限活力的热门图区。',
item: items
item: items,
};
};
+16 -12
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://www.jianshu.com/c/${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.jianshu.com/c/${id}`
}
Referer: `https://www.jianshu.com/c/${id}`,
},
});
const data = response.data;
@@ -23,14 +23,18 @@ module.exports = async (ctx) => {
title: $('title').text(),
link: `https://www.jianshu.com/c/${id}`,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`,
};
})
.get(),
};
};
};
+16 -12
View File
@@ -8,8 +8,8 @@ module.exports = async (ctx) => {
url: 'https://www.jianshu.com',
headers: {
'User-Agent': config.ua,
'Referer': 'https://www.jianshu.com'
}
Referer: 'https://www.jianshu.com',
},
});
const data = response.data;
@@ -21,14 +21,18 @@ module.exports = async (ctx) => {
title: '简书首页',
link: 'https://www.jianshu.com',
description: $('meta[name="description"]').attr('content'),
item: list && list.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`,
};
})
.get(),
};
};
};
+16 -12
View File
@@ -8,8 +8,8 @@ module.exports = async (ctx) => {
url: 'https://www.jianshu.com/trending/monthly',
headers: {
'User-Agent': config.ua,
'Referer': 'https://www.jianshu.com/trending/monthly'
}
Referer: 'https://www.jianshu.com/trending/monthly',
},
});
const data = response.data;
@@ -21,14 +21,18 @@ module.exports = async (ctx) => {
title: '简书 30 日热门',
link: 'https://www.jianshu.com/trending/monthly',
description: '简书 30 日热门',
item: list && list.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`,
};
})
.get(),
};
};
};
+16 -12
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://www.jianshu.com/u/${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.jianshu.com/u/${id}`
}
Referer: `https://www.jianshu.com/u/${id}`,
},
});
const data = response.data;
@@ -23,14 +23,18 @@ module.exports = async (ctx) => {
title: $('title').text(),
link: `https://www.jianshu.com/u/${id}`,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`,
};
})
.get(),
};
};
};
+16 -12
View File
@@ -8,8 +8,8 @@ module.exports = async (ctx) => {
url: 'https://www.jianshu.com/trending/weekly',
headers: {
'User-Agent': config.ua,
'Referer': 'https://www.jianshu.com/trending/weekly'
}
Referer: 'https://www.jianshu.com/trending/weekly',
},
});
const data = response.data;
@@ -21,14 +21,18 @@ module.exports = async (ctx) => {
title: '简书 7 日热门',
link: 'https://www.jianshu.com/trending/weekly',
description: '简书 7 日热门',
item: list && list.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: `作者:${item.find('.nickname').text()}<br>描述:${item.find('.abstract').text()}<br><img referrerpolicy="no-referrer" src="https:${item.find('.img-blur').data('echo')}">`,
pubDate: new Date(item.find('.time').data('shared-at')).toUTCString(),
link: `https://www.jianshu.com${item.find('.title').attr('href')}`,
};
})
.get(),
};
};
};
+15 -12
View File
@@ -9,9 +9,9 @@ module.exports = async (ctx) => {
url: `https://app.jike.ruguoapp.com/1.0/messages/showDetail?topicId=${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://m.okjike.com/topics/${id}`,
'App-Version': '3.5.0'
}
Referer: `https://m.okjike.com/topics/${id}`,
'App-Version': '3.5.0',
},
});
const data = response.data;
@@ -31,12 +31,15 @@ module.exports = async (ctx) => {
}
let imgTemplate = '';
item.pictureUrls && item.pictureUrls.forEach((item) => {
imgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`;
});
item.personalUpdate && item.personalUpdate.pictureUrls && item.personalUpdate.pictureUrls.forEach((item) => {
imgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`;
});
item.pictureUrls &&
item.pictureUrls.forEach((item) => {
imgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`;
});
item.personalUpdate &&
item.personalUpdate.pictureUrls &&
item.personalUpdate.pictureUrls.forEach((item) => {
imgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`;
});
let videoTemplate = '';
if (item.video) {
@@ -49,8 +52,8 @@ module.exports = async (ctx) => {
title: item.content,
description: `${contentTemplate}${imgTemplate}${videoTemplate}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: `https://web.okjike.com/message-detail/${item.id}/officialMessage`
}
link: `https://web.okjike.com/message-detail/${item.id}/officialMessage`,
};
}),
};
};
};
+29 -26
View File
@@ -9,14 +9,14 @@ module.exports = async (ctx) => {
url: 'https://app.jike.ruguoapp.com/1.0/personalUpdate/single',
headers: {
'User-Agent': config.ua,
'Referer': `https://web.okjike.com/user/${id}/post`,
Referer: `https://web.okjike.com/user/${id}/post`,
'App-Version': '4.1.0',
'platform': 'web'
platform: 'web',
},
data: {
limit: 20,
loadMoreKey: null,
username: id
username: id,
},
});
@@ -28,16 +28,16 @@ module.exports = async (ctx) => {
image: data[0].user.avatarImage.picUrl,
item: data.map((item) => {
const typeMap = {
'ORIGINAL_POST': '发布',
'REPOST': '转发',
'ANSWER': '回答'
ORIGINAL_POST: '发布',
REPOST: '转发',
ANSWER: '回答',
};
const linkMap = {
'OFFICIAL_MESSAGE': `https://web.okjike.com/message-detail/${item.id}/officialMessage`,
'ORIGINAL_POST': `https://web.okjike.com/post-detail/${item.id}/originalPost`,
'REPOST': `https://web.okjike.com/post-detail/${item.id}/repost`,
'ANSWER': `https://m.okjike.com/answers/${item.id}`
OFFICIAL_MESSAGE: `https://web.okjike.com/message-detail/${item.id}/officialMessage`,
ORIGINAL_POST: `https://web.okjike.com/post-detail/${item.id}/originalPost`,
REPOST: `https://web.okjike.com/post-detail/${item.id}/repost`,
ANSWER: `https://m.okjike.com/answers/${item.id}`,
};
let linkTemplate = '';
@@ -46,11 +46,12 @@ module.exports = async (ctx) => {
}
let imgTemplate = '';
item.pictures && item.pictures.forEach((item) => {
imgTemplate += `<img referrerpolicy="no-referrer" src="${item.picUrl}"><br>`;
});
item.pictures &&
item.pictures.forEach((item) => {
imgTemplate += `<img referrerpolicy="no-referrer" src="${item.picUrl}"><br>`;
});
let content = item.content || item.linkInfo && item.linkInfo.title || item.question && item.question.title || '';
let content = item.content || (item.linkInfo && item.linkInfo.title) || (item.question && item.question.title) || '';
let shortenTitle = '一条动态';
if (content) {
@@ -62,9 +63,10 @@ module.exports = async (ctx) => {
const screenNameTemplate = item.target.user ? `<a href="https://web.okjike.com/user/${item.target.user.username}/post" target="_blank">@${item.target.user.screenName}</a>` : '';
let repostImgTemplate = '';
item.target.pictures && item.target.pictures.forEach((item) => {
repostImgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.thumbnailUrl}">`;
});
item.target.pictures &&
item.target.pictures.forEach((item) => {
repostImgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.thumbnailUrl}">`;
});
const repostContent = `转发 ${screenNameTemplate}: ${item.target.content}${repostImgTemplate}`;
content = `${content}${repostContent}`.replace(/\n|\r/g, '<br>');
@@ -74,13 +76,14 @@ module.exports = async (ctx) => {
let answerTextTemplate = '';
let answerImgTemplate = '';
let answerImgKeys = [];
item.richtextContent.blocks && item.richtextContent.blocks.forEach((item) => {
if (item.entityRanges.length && item.text === '[图片]') {
answerImgKeys = [...answerImgKeys, ...Object.keys(item.entityRanges)];
} else {
answerTextTemplate += item.text;
}
});
item.richtextContent.blocks &&
item.richtextContent.blocks.forEach((item) => {
if (item.entityRanges.length && item.text === '[图片]') {
answerImgKeys = [...answerImgKeys, ...Object.keys(item.entityRanges)];
} else {
answerTextTemplate += item.text;
}
});
if (answerImgKeys.length) {
answerImgKeys.forEach((key) => {
@@ -98,8 +101,8 @@ module.exports = async (ctx) => {
title: `${typeMap[item.type]}了: ${shortenTitle}`,
description: `${content}${linkTemplate}${imgTemplate}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: `${linkMap[item.type]}`
}
link: `${linkMap[item.type]}`,
};
}),
};
};
+15 -12
View File
@@ -9,12 +9,12 @@ module.exports = async (ctx) => {
url: 'https://gold-tag-ms.juejin.im/v1/categories',
headers: {
'User-Agent': config.ua,
'Referer': `https://juejin.im/welcome/${category}`,
Referer: `https://juejin.im/welcome/${category}`,
'X-Juejin-Client': '',
'X-Juejin-Src': 'web',
'X-Juejin-Token': '',
'X-Juejin-Uid': ''
}
'X-Juejin-Uid': '',
},
});
const cat = idResponse.data.d.categoryList.filter((item) => item.title === category)[0];
@@ -25,8 +25,8 @@ module.exports = async (ctx) => {
url: `https://timeline-merger-ms.juejin.im/v1/get_entry_by_timeline?src=web&limit=20&category=${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://juejin.im/welcome/${category}`,
}
Referer: `https://juejin.im/welcome/${category}`,
},
});
const data = response.data;
@@ -35,11 +35,14 @@ module.exports = async (ctx) => {
title: `掘金${cat.name}`,
link: `https://juejin.im/welcome/${category}`,
description: `掘金${cat.name}`,
item: data.d && data.d.entrylist && data.d.entrylist.map((item) => ({
title: item.title,
description: `${(item.content || item.summaryInfo || '无描述').replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]/g, '')}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: item.originalUrl
})),
item:
data.d &&
data.d.entrylist &&
data.d.entrylist.map((item) => ({
title: item.title,
description: `${(item.content || item.summaryInfo || '无描述').replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]/g, '')}`,
pubDate: new Date(item.createdAt).toUTCString(),
link: item.originalUrl,
})),
};
};
};
+18 -14
View File
@@ -5,7 +5,7 @@ const config = require('../../config');
module.exports = async (ctx) => {
let category = ctx.params.category;
category = (category === undefined || category === 'undefined') ? '' : category;
category = category === undefined || category === 'undefined' ? '' : category;
const url = `http://www.mzitu.com/${category}`;
@@ -14,8 +14,8 @@ module.exports = async (ctx) => {
url: url,
headers: {
'User-Agent': config.ua,
Referer: url
}
Referer: url,
},
});
const data = response.data;
@@ -26,16 +26,20 @@ module.exports = async (ctx) => {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: linkA.attr('href')
};
}).get(),
item:
list &&
list
.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: linkA.attr('href'),
};
})
.get(),
};
};
+63 -57
View File
@@ -3,68 +3,74 @@ const cheerio = require('cheerio');
const config = require('../../config');
module.exports = async (ctx) => {
let id = ctx.params.id;
const id = ctx.params.id;
const url = `http://www.mzitu.com/${id}`;
const url = `http://www.mzitu.com/${id}`;
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
Referer: url
}
});
const data = response.data;
const $ = cheerio.load(data);
const img = $('.main-image > p > a > img');
const imgUrl = img.attr('src');
const prefix = imgUrl.substr(0, imgUrl.lastIndexOf('01.'));
const suffix = imgUrl.substr(imgUrl.lastIndexOf('.'));
let totalPage = $('.pagenavi > a:nth-last-child(2)').find('span').text();
totalPage = +totalPage;
const list = [{
url,
imgUrl,
page: 1
}];
for (let i = 2; i <= totalPage; i++) {
const p = i < 10 ? `0${i}` : i;
const nextImgUrl = `${prefix}${p}${suffix}`;
const nextUrl = `${url}/${i}`;
list.push({
url: nextUrl,
imgUrl: nextImgUrl,
page: i
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
Referer: url,
},
});
}
const title = $('title').text();
const data = response.data;
const $ = cheerio.load(data);
const reg = /[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d/;
const img = $('.main-image > p > a > img');
const imgUrl = img.attr('src');
ctx.state.data = {
title: title,
link: url,
description: $('meta[name="description"]').attr('content') || title,
item: list && list.map((item) => {
let date = new Date();
const dateStr = $('.main-meta > span:nth-child(2)').text();
if (reg.test(dateStr)) {
date = new Date(dateStr.match(reg)[0]);
}
const prefix = imgUrl.substr(0, imgUrl.lastIndexOf('01.'));
const suffix = imgUrl.substr(imgUrl.lastIndexOf('.'));
return {
title: `${title}${item.page}`,
description: `分类:${$('.main-meta > span:nth-child(1) > a').text()}<br>描述:${title}${item.page}<br><img referrerpolicy="no-referrer" src="${item.imgUrl}">`,
pubDate: date.toUTCString(),
link: item.url
};
})
};
let totalPage = $('.pagenavi > a:nth-last-child(2)')
.find('span')
.text();
totalPage = +totalPage;
const list = [
{
url,
imgUrl,
page: 1,
},
];
for (let i = 2; i <= totalPage; i++) {
const p = i < 10 ? `0${i}` : i;
const nextImgUrl = `${prefix}${p}${suffix}`;
const nextUrl = `${url}/${i}`;
list.push({
url: nextUrl,
imgUrl: nextImgUrl,
page: i,
});
}
const title = $('title').text();
const reg = /[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d/;
ctx.state.data = {
title: title,
link: url,
description: $('meta[name="description"]').attr('content') || title,
item:
list &&
list.map((item) => {
let date = new Date();
const dateStr = $('.main-meta > span:nth-child(2)').text();
if (reg.test(dateStr)) {
date = new Date(dateStr.match(reg)[0]);
}
return {
title: `${title}${item.page}`,
description: `分类:${$('.main-meta > span:nth-child(1) > a').text()}<br>描述:${title}${item.page}<br><img referrerpolicy="no-referrer" src="${item.imgUrl}">`,
pubDate: date.toUTCString(),
link: item.url,
};
}),
};
};
+18 -14
View File
@@ -4,7 +4,7 @@ const config = require('../../config');
module.exports = async (ctx) => {
let tag = ctx.params.tag;
tag = (tag === undefined || tag === 'undefined') ? '' : tag;
tag = tag === undefined || tag === 'undefined' ? '' : tag;
const url = `http://www.mzitu.com/tag/${tag}`;
@@ -13,8 +13,8 @@ module.exports = async (ctx) => {
url: url,
headers: {
'User-Agent': config.ua,
Referer: url
}
Referer: url,
},
});
const data = response.data;
@@ -25,16 +25,20 @@ module.exports = async (ctx) => {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: linkA.attr('href')
};
}).get(),
item:
list &&
list
.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: linkA.attr('href'),
};
})
.get(),
};
};
+32 -29
View File
@@ -3,36 +3,39 @@ const cheerio = require('cheerio');
const config = require('../../config');
module.exports = async (ctx) => {
const url = 'http://www.mzitu.com/zhuanti';
const url = 'http://www.mzitu.com/zhuanti';
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
Referer: url,
},
});
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
Referer: url
}
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.main-content > div.postlist > dl > dd');
const data = response.data;
const $ = cheerio.load(data);
const list = $('.main-content > div.postlist > dl > dd');
ctx.state.data = {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item: list && list.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `${item.find('i').text()}<br>描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: '',
link: linkA.attr('href')
};
}).get(),
};
ctx.state.data = {
title: $('title').text(),
link: url,
description: $('meta[name="description"]').attr('content') || $('title').text(),
item:
list &&
list
.map((item, index) => {
item = $(index);
const linkA = item.find('a');
const previewImg = linkA.find('img');
return {
title: previewImg.attr('alt'),
description: `${item.find('i').text()}<br>描述:${previewImg.attr('alt')}<br><img referrerpolicy="no-referrer" src="${previewImg.data('original')}">`,
pubDate: '',
link: linkA.attr('href'),
};
})
.get(),
};
};
+4 -4
View File
@@ -9,8 +9,8 @@ module.exports = async (ctx) => {
url: `https://music.163.com/api/artist/albums/${id}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://music.163.com/'
}
Referer: 'https://music.163.com/',
},
});
const data = response.data;
@@ -24,8 +24,8 @@ module.exports = async (ctx) => {
return {
title: `${item.name} - ${singer}`,
description: `歌手:${singer}<br>专辑:${item.name}<br>日期:${new Date(item.publishTime).toLocaleDateString()}<br><img referrerpolicy="no-referrer" src="${item.picUrl}">`,
link: `https://music.163.com/#/album?id=${item.id}`
link: `https://music.163.com/#/album?id=${item.id}`,
};
}),
};
};
};
+13 -11
View File
@@ -10,11 +10,11 @@ module.exports = async (ctx) => {
url: 'https://music.163.com/api/v3/playlist/detail',
headers: {
'User-Agent': config.ua,
'Referer': 'https://music.163.com/',
Referer: 'https://music.163.com/',
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
id: id
id: id,
}),
});
@@ -24,13 +24,15 @@ module.exports = async (ctx) => {
title: data.name,
link: `https://music.163.com/#/playlist?id=${id}`,
description: `网易云音乐歌单 - ${data.name}`,
item: data.tracks && data.tracks.map((item) => {
const singer = item.ar.length === 1 ? item.ar[0].name : item.ar.reduce((prev, cur) => (prev.name || prev) + '/' + cur.name);
return {
title: `${item.name} - ${singer}`,
description: `歌手:${singer}<br>专辑:${item.al.name}<br>日期:${new Date(item.publishTime).toLocaleDateString()}<br><img referrerpolicy="no-referrer" src="${item.al.picUrl}">`,
link: `https://music.163.com/#/song?id=${item.id}`
};
}),
item:
data.tracks &&
data.tracks.map((item) => {
const singer = item.ar.length === 1 ? item.ar[0].name : item.ar.reduce((prev, cur) => (prev.name || prev) + '/' + cur.name);
return {
title: `${item.name} - ${singer}`,
description: `歌手:${singer}<br>专辑:${item.al.name}<br>日期:${new Date(item.publishTime).toLocaleDateString()}<br><img referrerpolicy="no-referrer" src="${item.al.picUrl}">`,
link: `https://music.163.com/#/song?id=${item.id}`,
};
}),
};
};
};
+5 -5
View File
@@ -10,13 +10,13 @@ module.exports = async (ctx) => {
url: 'http://music.163.com/api/user/playlist',
headers: {
'User-Agent': config.ua,
'Referer': 'https://music.163.com/',
Referer: 'https://music.163.com/',
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
uid: uid,
limit: 1000,
offset: 0
offset: 0,
}),
});
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
title: pl.name,
description: pl.description,
pubDate: new Date(pl.createTime).toUTCString(),
link: `http://music.163.com/playlist?id=${pl.id}`
}))
link: `http://music.163.com/playlist?id=${pl.id}`,
})),
};
};
};
+14 -15
View File
@@ -1,25 +1,24 @@
const axios = require('axios');
const maskHeader = require('../constants').maskHeader;
/**
* 获取用户的收藏
*
*
* @param {string} user_id 目标用户id
* @param {string} token pixiv oauth token
* @returns {Promise<axios.AxiosResponse<{illusts: illust[]}>>}
*/
module.exports = async function getBookmarks(user_id, token) {
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/bookmarks/illust',
headers: {
...maskHeader,
'Authorization': 'Bearer ' + token
},
params: {
user_id: user_id,
restrict: 'public'
},
});
}
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/bookmarks/illust',
headers: {
...maskHeader,
Authorization: 'Bearer ' + token,
},
params: {
user_id: user_id,
restrict: 'public',
},
});
};
+14 -14
View File
@@ -8,17 +8,17 @@ const maskHeader = require('../constants').maskHeader;
* @returns {Promise<axios.AxiosResponse<{illusts: illust[]}>>}
*/
module.exports = async function getIllusts(user_id, token) {
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/illusts',
headers: {
...maskHeader,
'Authorization': 'Bearer ' + token
},
params: {
user_id: user_id,
filter: 'for_ios',
type: 'illust'
},
})
}
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/illusts',
headers: {
...maskHeader,
Authorization: 'Bearer ' + token,
},
params: {
user_id: user_id,
filter: 'for_ios',
type: 'illust',
},
});
};
+18 -20
View File
@@ -2,9 +2,7 @@ const axios = require('axios');
const maskHeader = require('../constants').maskHeader;
const assert = require('assert');
const allowMode = [
'day', 'week', 'month', 'day_male', 'day_female', 'week_original', 'week_rookie', 'day_r18', 'day_male_r18', 'day_female_r18', 'week_r18', 'week_r18g'
];
const allowMode = ['day', 'week', 'month', 'day_male', 'day_female', 'week_original', 'week_rookie', 'day_r18', 'day_male_r18', 'day_female_r18', 'week_r18', 'week_r18g'];
/**
* 获取某天的排行榜
@@ -14,20 +12,20 @@ const allowMode = [
* @returns {Promise<axios.AxiosResponse<{illusts: illust[]}>>}
*/
module.exports = async function getRanking(mode, date, token) {
assert(allowMode.includes(mode), 'Mode not allow.');
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/illust/ranking',
headers: {
...maskHeader,
'Authorization': 'Bearer ' + token
},
params: {
mode: mode,
filter: 'for_ios',
...(date && {
date: `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
})
},
});
}
assert(allowMode.includes(mode), 'Mode not allow.');
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/illust/ranking',
headers: {
...maskHeader,
Authorization: 'Bearer ' + token,
},
params: {
mode: mode,
filter: 'for_ios',
...(date && {
date: `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`,
}),
},
});
};
+13 -14
View File
@@ -1,4 +1,3 @@
const axios = require('axios');
const maskHeader = require('../constants').maskHeader;
@@ -9,21 +8,21 @@ const maskHeader = require('../constants').maskHeader;
/**
* 获取用户信息
*
*
* @param {string} user_id 目标用户id
* @param {string} token pixiv oauth token
* @returns {Promise<axios.AxiosResponse<userDetail>>}
*/
module.exports = async function getUserDetail(user_id, token) {
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/detail',
headers: {
...maskHeader,
'Authorization': 'Bearer ' + token
},
params: {
user_id: user_id
},
});
}
return await axios({
method: 'get',
url: 'https://app-api.pixiv.net/v1/user/detail',
headers: {
...maskHeader,
Authorization: 'Bearer ' + token,
},
params: {
user_id: user_id,
},
});
};
+4 -7
View File
@@ -10,10 +10,7 @@ module.exports = async (ctx) => {
return;
}
const [bookmarksResponse, userDetailResponse] = await Promise.all([
getBookmarks(id, getToken()),
getUserDetail(id, getToken())
]);
const [bookmarksResponse, userDetailResponse] = await Promise.all([getBookmarks(id, getToken()), getUserDetail(id, getToken())]);
const illusts = bookmarksResponse.data.illusts;
const username = userDetailResponse.data.user.name;
@@ -34,8 +31,8 @@ module.exports = async (ctx) => {
return {
title: `${illust.title}`,
description: `<p>画师:${illust.user.name} - 上传于:${new Date(illust.create_date).toLocaleString('zh-cn')} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}</p>${images.join('')}`,
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`,
};
})
}),
};
};
};
+2 -2
View File
@@ -3,6 +3,6 @@ exports.modules = {
'App-OS': 'ios',
'App-OS-Version': '10.3.1',
'App-Version': '6.7.1',
'User-Agent': 'PixivIOSApp/6.7.1 (iOS 10.3.1; iPhone8,1)'
}
'User-Agent': 'PixivIOSApp/6.7.1 (iOS 10.3.1; iPhone8,1)',
},
};
+27 -27
View File
@@ -2,33 +2,33 @@ const getToken = require('./token');
const getRanking = require('./api/getRanking');
const titles = {
'day': 'pixiv 日排行',
'week': 'pixiv 周排行',
'month': 'pixiv 月排行',
'day_male': 'pixiv 受男性欢迎排行',
'day_female': 'pixiv 受女性欢迎排行',
'week_original': 'pixiv 原创作品排行',
'week_rookie': 'pixiv 新人排行',
'day_r18': 'pixiv R-18 日排行',
'day_male_r18': 'pixiv R-18 受男性欢迎排行',
'day_female_r18': 'pixiv R-18 受女性欢迎排行',
'week_r18': 'pixiv R-18 周排行',
'week_r18g': 'pixiv R-18G 排行'
day: 'pixiv 日排行',
week: 'pixiv 周排行',
month: 'pixiv 月排行',
day_male: 'pixiv 受男性欢迎排行',
day_female: 'pixiv 受女性欢迎排行',
week_original: 'pixiv 原创作品排行',
week_rookie: 'pixiv 新人排行',
day_r18: 'pixiv R-18 日排行',
day_male_r18: 'pixiv R-18 受男性欢迎排行',
day_female_r18: 'pixiv R-18 受女性欢迎排行',
week_r18: 'pixiv R-18 周排行',
week_r18g: 'pixiv R-18G 排行',
};
const links = {
'day': 'https://www.pixiv.net/ranking.php?mode=daily',
'week': 'https://www.pixiv.net/ranking.php?mode=weekly',
'month': 'https://www.pixiv.net/ranking.php?mode=monthly',
'day_male': 'https://www.pixiv.net/ranking.php?mode=male',
'day_female': 'https://www.pixiv.net/ranking.php?mode=female',
'week_original': 'https://www.pixiv.net/ranking.php?mode=original',
'week_rookie': 'https://www.pixiv.net/ranking.php?mode=rookie',
'day_r18': 'https://www.pixiv.net/ranking.php?mode=daily_r18',
'day_male_r18': 'https://www.pixiv.net/ranking.php?mode=male_r18',
'day_female_r18': 'https://www.pixiv.net/ranking.php?mode=female_r18',
'week_r18': 'https://www.pixiv.net/ranking.php?mode=weekly_r18',
'week_r18g': 'https://www.pixiv.net/ranking.php?mode=r18g'
day: 'https://www.pixiv.net/ranking.php?mode=daily',
week: 'https://www.pixiv.net/ranking.php?mode=weekly',
month: 'https://www.pixiv.net/ranking.php?mode=monthly',
day_male: 'https://www.pixiv.net/ranking.php?mode=male',
day_female: 'https://www.pixiv.net/ranking.php?mode=female',
week_original: 'https://www.pixiv.net/ranking.php?mode=original',
week_rookie: 'https://www.pixiv.net/ranking.php?mode=rookie',
day_r18: 'https://www.pixiv.net/ranking.php?mode=daily_r18',
day_male_r18: 'https://www.pixiv.net/ranking.php?mode=male_r18',
day_female_r18: 'https://www.pixiv.net/ranking.php?mode=female_r18',
week_r18: 'https://www.pixiv.net/ranking.php?mode=weekly_r18',
week_r18g: 'https://www.pixiv.net/ranking.php?mode=r18g',
};
module.exports = async (ctx) => {
@@ -62,8 +62,8 @@ module.exports = async (ctx) => {
return {
title: `#${index + 1} ${illust.title}`,
description: `<p>画师:${illust.user.name} - 上传于:${new Date(illust.create_date).toLocaleString('zh-cn')} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}</p><br>${images.join('')}`,
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`,
};
})
}),
};
};
};
+16 -15
View File
@@ -10,10 +10,10 @@ const pixivConfig = config.pixiv;
let token = null;
const authorizationInfo = {
client_id: pixivConfig.client_id,
client_secret: pixivConfig.client_secret,
username: pixivConfig.username,
password: pixivConfig.password
client_id: pixivConfig.client_id,
client_secret: pixivConfig.client_secret,
username: pixivConfig.username,
password: pixivConfig.password,
};
async function getToken() {
@@ -21,19 +21,19 @@ async function getToken() {
const jsonData = {
...authorizationInfo,
get_secure_url: 1,
grant_type: 'password'
grant_type: 'password',
};
for (const key in jsonData) {
if (jsonData.hasOwnProperty(key)) {
const element = jsonData[key];
data.append(key,element);
data.append(key, element);
}
}
const response = await axios.post('https://oauth.secure.pixiv.net/auth/token', data, {
headers: {
...maskHeader,
...data.getHeaders()
}
...data.getHeaders(),
},
});
return response.data.response;
}
@@ -44,19 +44,19 @@ async function refreshToken(refresh_token) {
...authorizationInfo,
get_secure_url: 1,
grant_type: 'refresh_token',
refresh_token: refresh_token
refresh_token: refresh_token,
};
for (const key in jsonData) {
if (jsonData.hasOwnProperty(key)) {
const element = jsonData[key];
data.append(key,element);
data.append(key, element);
}
}
const response = await axios.post('https://oauth.secure.pixiv.net/auth/token', data, {
headers: {
...maskHeader,
...data.getHeaders()
}
...data.getHeaders(),
},
});
return response.data.response;
}
@@ -67,6 +67,7 @@ async function tokenLoop() {
token = res.access_token;
let refresh_token = res.refresh_token;
let expires_in = res.expires_in * 0.9;
// eslint-disable-next-line no-constant-condition
while (true) {
await wait(expires_in * 1000);
try {
@@ -77,7 +78,7 @@ async function tokenLoop() {
expires_in = refresh_res.expires_in * 0.9;
} catch (err) {
expires_in = 30;
logger.err('Pixiv refresh token failed, retry in ${expires_in} seconds.', err);
logger.err(`Pixiv refresh token failed, retry in ${expires_in} seconds.`, err);
}
}
}
@@ -85,5 +86,5 @@ async function tokenLoop() {
tokenLoop();
module.exports = function getToken() {
return token;
};
return token;
};
+3 -3
View File
@@ -30,8 +30,8 @@ module.exports = async (ctx) => {
return {
title: illust.title,
description: `<p>画师:${username} - 上传于:${new Date(illust.create_date).toLocaleString('zh-cn')} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}</p>${images.join('')}`,
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`,
};
})
}),
};
};
};
+18 -18
View File
@@ -2,19 +2,19 @@ const axios = require('axios');
const cheerio = require('cheerio');
const config = require('../../config');
function isNormalTime (time) {
function isNormalTime(time) {
return /^(\d{2}):(\d{2})$/.test(time);
}
function isNormalDate (time) {
function isNormalDate(time) {
return /^(\d{1,2})-(\d{1,2})$/.test(time);
}
function isDate (time) {
function isDate(time) {
return /^(\d{4})-(\d{1,2})-(\d{1,2})$/.test(time);
}
function getPubDate (time) {
function getPubDate(time) {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
@@ -45,10 +45,10 @@ module.exports = async (ctx) => {
},
});
const threadListHTML = cheerio.
load(data)('code[id="pagelet_html_frs-list/pagelet/thread_list"]').
html().
replace(/<!--|-->/g, '');
const threadListHTML = cheerio
.load(data)('code[id="pagelet_html_frs-list/pagelet/thread_list"]')
.html()
.replace(/<!--|-->/g, '');
const $ = cheerio.load(threadListHTML);
const list = $('#thread_list > .j_thread_list[data-field]');
@@ -58,21 +58,21 @@ module.exports = async (ctx) => {
link: `https://tieba.baidu.com/f?kw=${encodeURIComponent(kw)}`,
item:
list &&
list.
map((index, element) => {
list
.map((index, element) => {
const item = $(element);
const { id, author_name } = item.data('field');
const time = item.find('.threadlist_reply_date').text().trim(); // prettier-ignore
const title = item.find('a.j_th_tit').text().trim(); // prettier-ignore
const details = item.find('.threadlist_abs').text().trim(); // prettier-ignore
const medias = item.
find('.threadlist_media img').
map((index, element) => {
const medias = item
.find('.threadlist_media img')
.map((index, element) => {
const item = $(element);
return `<img referrerpolicy="no-referrer" src="${item.attr('bpic')}">`; // prettier-ignore
}).
get().
join('');
})
.get()
.join('');
return {
title,
@@ -80,7 +80,7 @@ module.exports = async (ctx) => {
pubDate: getPubDate(time).toUTCString(),
link: `https://tieba.baidu.com/p/${id}`,
};
}).
get(),
})
.get(),
};
};
+31 -12
View File
@@ -2,30 +2,49 @@ const axios = require('axios');
const cheerio = require('cheerio');
const config = require('../../config');
const baseUrl = 'https://toutiao.io'
module.exports = async (ctx)=>{
const baseUrl = 'https://toutiao.io';
module.exports = async (ctx) => {
const response = await axios({
method:'get',
url:baseUrl,
method: 'get',
url: baseUrl,
headers: {
'User-Agent': config.ua,
'Host':'toutiao.io'
Host: 'toutiao.io',
},
responseType: 'text'
responseType: 'text',
});
const $ = cheerio.load(response.data);
const title = $('#daily').find('.date>span').eq(0).text() + ' ' + $('#daily').find('.date>small').eq(0).text();
const title =
$('#daily')
.find('.date>span')
.eq(0)
.text() +
' ' +
$('#daily')
.find('.date>small')
.eq(0)
.text();
const list = $('.posts>.post', '#daily');
const article_item = [];
for(let i=0;i<list.length;i++){
const article_el = $(list[i]).find('.content').eq(0);
for (let i = 0; i < list.length; i++) {
const article_el = $(list[i])
.find('.content')
.eq(0);
const item = {
title: article_el.find('a').eq(0).text(),
link: baseUrl + article_el.find('a').eq(0).attr('href')
title: article_el
.find('a')
.eq(0)
.text(),
link:
baseUrl +
article_el
.find('a')
.eq(0)
.attr('href'),
};
article_item.push(item);
};
}
ctx.state.data = {
title: '开发者头条:' + title,
link: baseUrl,
+35 -17
View File
@@ -3,37 +3,55 @@ const cheerio = require('cheerio');
const config = require('../../config');
const baseUrl = 'https://toutiao.io';
module.exports = async (ctx)=>{
module.exports = async (ctx) => {
const id = ctx.params.id;
let requestUrl = `${baseUrl}/subjects/${id}?f=new`;
const requestUrl = `${baseUrl}/subjects/${id}?f=new`;
const response = await axios({
method:'get',
url:requestUrl,
method: 'get',
url: requestUrl,
headers: {
'User-Agent': config.ua,
'Host':'toutiao.io'
Host: 'toutiao.io',
},
responseType: 'text'
responseType: 'text',
});
const $ = cheerio.load(response.data);
const image = $('#main').find('.text-center>.subject-cover>img').eq(0).attr('src');
const link = requestUrl;
const title = $('#main').find('.text-center>h3').eq(0).text();
const description = $('#main').find('.social-share-button').eq(0).attr('data-title');
const image = $('#main')
.find('.text-center>.subject-cover>img')
.eq(0)
.attr('src');
const title = $('#main')
.find('.text-center>h3')
.eq(0)
.text();
const description = $('#main')
.find('.social-share-button')
.eq(0)
.attr('data-title');
const list = $('.posts>.post', '#main');
const article_item = [];
for(let i=0;i<list.length;i++){
const article_el = $(list[i]).find('.content').eq(0);
for (let i = 0; i < list.length; i++) {
const article_el = $(list[i])
.find('.content')
.eq(0);
const item = {
title: article_el.find('a').eq(0).text(),
link: baseUrl + article_el.find('a').eq(0).attr('href')
title: article_el
.find('a')
.eq(0)
.text(),
link:
baseUrl +
article_el
.find('a')
.eq(0)
.attr('href'),
};
article_item.push(item);
};
}
ctx.state.data = {
title: '开发者头条独家号:'+title,
description:description,
title: '开发者头条独家号:' + title,
description: description,
image: image,
link: baseUrl,
item: article_item,
+5 -6
View File
@@ -2,7 +2,6 @@ const axios = require('axios');
const config = require('../../config');
const md5 = require('../../utils/md5');
module.exports = async (ctx) => {
const projectID = ctx.params.project;
const key = ctx.params.key;
@@ -12,9 +11,9 @@ module.exports = async (ctx) => {
url: `https://support.qq.com/api/v1/${projectID}/posts`,
headers: {
'User-Agent': config.ua,
'Timestamp': Math.round(+new Date() / 1000).toString(),
'Signature': md5(Math.round(+new Date() / 1000).toString() + key)
}
Timestamp: Math.round(+new Date() / 1000).toString(),
Signature: md5(Math.round(+new Date() / 1000).toString() + key),
},
});
const data = response.data.data;
@@ -23,7 +22,7 @@ module.exports = async (ctx) => {
link: `https://support.qq.com/product/${projectID}`,
description: `${projectID} 的 吐个槽新帖`,
item: data.map((item) => {
let pubdate = new Date(item.created_at.replace(' ', 'T') + "+08:00");
const pubdate = new Date(item.created_at.replace(' ', 'T') + '+08:00');
let imgHTML = '';
if (data.images) {
for (let i = 0; i < data.images.length; i++) {
@@ -35,7 +34,7 @@ module.exports = async (ctx) => {
description: `${item.content}${imgHTML}`,
pubDate: pubdate.toUTCString(),
link: `https://support.qq.com/products/${projectID}`,
guid: `https://support.qq.com/products/${projectID} ${item.id}`
guid: `https://support.qq.com/products/${projectID} ${item.id}`,
};
}),
};
+3 -3
View File
@@ -7,7 +7,7 @@ module.exports = async (ctx) => {
const id = ctx.params.id;
const result = await T.get('statuses/user_timeline', {
screen_name: id
screen_name: id,
});
const data = result.data;
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
title: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text.length > 30 ? item.text.slice(0, 30) + '...' : item.text}`,
description: `${item.in_reply_to_screen_name ? 'Re ' : ''}${item.text}`,
pubDate: new Date(item.createdTime).toUTCString(),
link: `https://twitter.com/${id}/status/${item.id_str}`
link: `https://twitter.com/${id}/status/${item.id_str}`,
})),
};
};
};
+4 -4
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://m.weibo.cn/api/container/getIndex?containerid=100103type%3D61%26q%3D${encodeURIComponent(keyword)}%26t%3D0`,
headers: {
'User-Agent': config.ua,
'Referer': `https://m.weibo.cn/p/searchall?containerid=100103type%3D1%26q%3D${encodeURIComponent(keyword)}`
}
Referer: `https://m.weibo.cn/p/searchall?containerid=100103type%3D1%26q%3D${encodeURIComponent(keyword)}`,
},
});
const data = response.data.data.cards[0].card_group;
@@ -25,8 +25,8 @@ module.exports = async (ctx) => {
title: `${item.mblog.user.screen_name}: ${title.length > 24 ? title.slice(0, 24) + '...' : title}`,
description: `${item.mblog.user.screen_name}: ${weiboUtils.format(item.mblog)}`,
pubDate: weiboUtils.getTime(item.mblog.created_at),
link: `https://weibo.com/${item.mblog.user.id}/${item.mblog.bid}`
link: `https://weibo.com/${item.mblog.user.id}/${item.mblog.bid}`,
};
}),
};
};
};
+6 -6
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': 'https://m.weibo.cn/'
}
Referer: 'https://m.weibo.cn/',
},
});
const name = containerResponse.data.data.userInfo.screen_name;
const containerid = containerResponse.data.data.tabsInfo.tabs[1].containerid;
@@ -21,8 +21,8 @@ module.exports = async (ctx) => {
url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}&containerid=${containerid}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://m.weibo.cn/u/${uid}`
}
Referer: `https://m.weibo.cn/u/${uid}`,
},
});
ctx.state.data = {
@@ -35,8 +35,8 @@ module.exports = async (ctx) => {
title: title.length > 24 ? title.slice(0, 24) + '...' : title,
description: weiboUtils.format(item.mblog),
pubDate: weiboUtils.getTime(item.mblog.created_at),
link: `https://weibo.com/${uid}/${item.mblog.bid}`
link: `https://weibo.com/${uid}/${item.mblog.bid}`,
};
}),
};
};
};
+9 -6
View File
@@ -11,19 +11,19 @@ module.exports = async (ctx) => {
url: `http://service.weibo.com/widget/widget_blog.php?uid=${uid}`,
headers: {
'User-Agent': config.ua,
'Referer': `http://service.weibo.com/widget/widget_blog.php?uid=${uid}`
}
Referer: `http://service.weibo.com/widget/widget_blog.php?uid=${uid}`,
},
});
const data = response.data;
const $ = cheerio.load(data, {
decodeEntities: false
decodeEntities: false,
});
const wbs = [];
const items = $('.wgtCell');
let wb, item, titleEle;
items.map((index, ele) => {
items.forEach((index, ele) => {
wb = {};
item = $(ele);
titleEle = item.find('.wgtCell_txt');
@@ -31,7 +31,10 @@ module.exports = async (ctx) => {
if (wb.title.length > 24) {
wb.title = wb.title.slice(0, 24) + '...';
}
wb.description = titleEle.html().replace(/^\s+|\s+$/g, '').replace(/thumbnail/, 'large');
wb.description = titleEle
.html()
.replace(/^\s+|\s+$/g, '')
.replace(/thumbnail/, 'large');
wb.pubDate = weiboUtils.getTime(item.find('.link_d').html());
wb.link = item.find('.wgtCell_tm a').attr('href');
wbs.push(wb);
@@ -43,4 +46,4 @@ module.exports = async (ctx) => {
link: `http://weibo.com/${uid}/`,
item: wbs,
};
};
};
+4 -4
View File
@@ -12,7 +12,7 @@ const weiboUtils = {
temp += '<br><br>';
// 处理外部链接
temp = temp.replace(/https:\/\/weibo\.cn\/sinaurl\/.*?&u=(http.*?")/g, function (match, p1) {
temp = temp.replace(/https:\/\/weibo\.cn\/sinaurl\/.*?&u=(http.*?")/g, function(match, p1) {
return decodeURIComponent(p1);
});
@@ -28,7 +28,7 @@ const weiboUtils = {
// 添加微博配图
if (status.pics) {
status.pics.forEach(function (item) {
status.pics.forEach(function(item) {
temp += '<img referrerpolicy="no-referrer" src="' + item.large.url + '"><br><br>';
});
}
@@ -68,7 +68,7 @@ const weiboUtils = {
return date.toUTCString();
}
return html;
}
},
};
module.exports = weiboUtils;
module.exports = weiboUtils;
+4 -4
View File
@@ -3,7 +3,7 @@ const config = require('../../config');
const youtube = google.youtube({
version: 'v3',
auth: config.youtube.key
auth: config.youtube.key,
});
module.exports = async (ctx) => {
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
const responst = await youtube.playlistItems.list({
part: 'snippet,contentDetails,status',
playlistId: playlistId
playlistId: playlistId,
});
const data = responst.data.items;
@@ -32,8 +32,8 @@ module.exports = async (ctx) => {
title: snippet.title,
description: `${snippet.description}<img referrerpolicy="no-referrer" src="${img.url}">`,
pubDate: new Date(snippet.publishedAt).toUTCString(),
link: `https://www.youtube.com/watch?v=${snippet.resourceId.videoId}`
link: `https://www.youtube.com/watch?v=${snippet.resourceId.videoId}`,
};
}),
};
};
};
+4 -4
View File
@@ -3,7 +3,7 @@ const config = require('../../config');
const youtube = google.youtube({
version: 'v3',
auth: config.youtube.key
auth: config.youtube.key,
});
module.exports = async (ctx) => {
@@ -17,7 +17,7 @@ module.exports = async (ctx) => {
const responst = await youtube.playlistItems.list({
part: 'snippet,contentDetails,status',
playlistId: playlistId
playlistId: playlistId,
});
const data = responst.data.items;
@@ -32,8 +32,8 @@ module.exports = async (ctx) => {
title: snippet.title,
description: `${snippet.description}<img referrerpolicy="no-referrer" src="${img.url}">`,
pubDate: new Date(snippet.publishedAt).toUTCString(),
link: `https://www.youtube.com/watch?v=${snippet.resourceId.videoId}`
link: `https://www.youtube.com/watch?v=${snippet.resourceId.videoId}`,
};
}),
};
};
};
+67 -65
View File
@@ -9,10 +9,10 @@ module.exports = async (ctx) => {
url: `https://www.zhihu.com/api/v4/members/${id}/activities?limit=7`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.zhihu.com/people/${id}/activities`,
'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',
'X-API-VERSION': '3.0.40'
}
Referer: `https://www.zhihu.com/people/${id}/activities`,
authorization: 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',
'X-API-VERSION': '3.0.40',
},
});
const data = response.data.data;
@@ -21,68 +21,70 @@ module.exports = async (ctx) => {
title: `${data[0].actor.name}的知乎动态`,
link: `https://www.zhihu.com/people/${id}/activities`,
description: data[0].actor.headline || data[0].actor.description,
item: data && data.map((item) => {
const detail = item.target;
let title;
let description;
let url;
const images = [];
let text = '';
let link = '';
item:
data &&
data.map((item) => {
const detail = item.target;
let title;
let description;
let url;
const images = [];
let text = '';
let link = '';
switch (item.target.type) {
case 'answer':
title = detail.question.title;
description = detail.content;
url = `https://www.zhihu.com/question/${detail.question.id}/answer/${detail.id}`;
break;
case 'article':
title = detail.title;
description = detail.content;
url = `https://zhuanlan.zhihu.com/p/${detail.id}`;
break;
case 'pin':
title = detail.excerpt_title.length > 17 ? detail.excerpt_title.slice(0, 17) + '...' : detail.excerpt_title;
detail.content.forEach((contentItem) => {
if (contentItem.type === 'text') {
text = `<p>${contentItem.own_text}</p>`;
} else if (contentItem.type === 'image') {
images.push(`<p><img referrerpolicy="no-referrer" src="${contentItem.url.replace('xl', 'r')}"/></p>`);
} else if (contentItem.type === 'link') {
link = `<p><a href="${contentItem.url}" target="_blank">${contentItem.title}</a></p>`;
}
});
description = `${text}${link}${images.join('')}`;
url = `https://www.zhihu.com/pin/${detail.id}`;
break;
case 'question':
title = detail.title;
description = detail.excerpt;
url = `https://www.zhihu.com/question/${detail.id}`;
break;
case 'column':
title = detail.title;
description = `<p>${detail.intro}</p><p><img referrerpolicy="no-referrer" src="${detail.image_url}"/></p>`;
url = detail.url;
break;
case 'topic':
title = detail.name;
description = `<p>${detail.introduction}</p><p>话题关注者人数:${detail.followers_count}</p>`;
url = detail.url;
break;
case 'live':
title = detail.subject;
description = detail.description.replace(/\n|\r/g, '<br>');
url = `https://www.zhihu.com/lives/${detail.id}`;
break;
}
switch (item.target.type) {
case 'answer':
title = detail.question.title;
description = detail.content;
url = `https://www.zhihu.com/question/${detail.question.id}/answer/${detail.id}`;
break;
case 'article':
title = detail.title;
description = detail.content;
url = `https://zhuanlan.zhihu.com/p/${detail.id}`;
break;
case 'pin':
title = detail.excerpt_title.length > 17 ? detail.excerpt_title.slice(0, 17) + '...' : detail.excerpt_title;
detail.content.forEach((contentItem) => {
if (contentItem.type === 'text') {
text = `<p>${contentItem.own_text}</p>`;
} else if (contentItem.type === 'image') {
images.push(`<p><img referrerpolicy="no-referrer" src="${contentItem.url.replace('xl', 'r')}"/></p>`);
} else if (contentItem.type === 'link') {
link = `<p><a href="${contentItem.url}" target="_blank">${contentItem.title}</a></p>`;
}
});
description = `${text}${link}${images.join('')}`;
url = `https://www.zhihu.com/pin/${detail.id}`;
break;
case 'question':
title = detail.title;
description = detail.excerpt;
url = `https://www.zhihu.com/question/${detail.id}`;
break;
case 'column':
title = detail.title;
description = `<p>${detail.intro}</p><p><img referrerpolicy="no-referrer" src="${detail.image_url}"/></p>`;
url = detail.url;
break;
case 'topic':
title = detail.name;
description = `<p>${detail.introduction}</p><p>话题关注者人数:${detail.followers_count}</p>`;
url = detail.url;
break;
case 'live':
title = detail.subject;
description = detail.description.replace(/\n|\r/g, '<br>');
url = `https://www.zhihu.com/lives/${detail.id}`;
break;
}
return {
title: `${item.action_text}: ${title}`,
description: description,
pubDate: new Date(item.created_time * 1000).toUTCString(),
link: url
};
}),
return {
title: `${item.action_text}: ${title}`,
description: description,
pubDate: new Date(item.created_time * 1000).toUTCString(),
link: url,
};
}),
};
};
+12 -10
View File
@@ -9,10 +9,10 @@ module.exports = async (ctx) => {
url: `https://www.zhihu.com/api/v4/members/${id}/answers?include=data%5B*%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Cmark_infos%2Ccreated_time%2Cupdated_time%2Creview_info%2Cquestion%2Cexcerpt%2Crelationship.is_authorized%2Cvoting%2Cis_author%2Cis_thanked%2Cis_nothelp%3Bdata%5B*%5D.author.badge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=0&limit=7&sort_by=created`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.zhihu.com/people/${id}/answers`,
'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',
'X-API-VERSION': '3.0.40'
}
Referer: `https://www.zhihu.com/people/${id}/answers`,
authorization: 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',
'X-API-VERSION': '3.0.40',
},
});
const data = response.data.data;
@@ -21,11 +21,13 @@ module.exports = async (ctx) => {
title: `${data[0].author.name}的知乎回答`,
link: `https://www.zhihu.com/people/${id}/answers`,
description: data[0].author.headline || data[0].author.description,
item: data && data.map((item) => ({
title: item.question.title,
description: item.content,
pubDate: new Date(item.created_time * 1000).toUTCString(),
link: `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`
})),
item:
data &&
data.map((item) => ({
title: item.question.title,
description: item.content,
pubDate: new Date(item.created_time * 1000).toUTCString(),
link: `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`,
})),
};
};
+18 -12
View File
@@ -10,8 +10,8 @@ module.exports = async (ctx) => {
url: `https://www.zhihu.com/collection/${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://www.zhihu.com/collection/${id}`
}
Referer: `https://www.zhihu.com/collection/${id}`,
},
});
const data = response.data;
@@ -22,15 +22,21 @@ module.exports = async (ctx) => {
title: $('title').text(),
link: `https://www.zhihu.com/collection/${id}`,
description: `${$('#zh-fav-head-description').text()}`,
item: list && list.map((index, item) => {
item = $(item);
let linkUrl = item.find('link').attr('href');
if (linkUrl.startsWith('/')) linkUrl = 'https://www.zhihu.com' + linkUrl;
return {
title: item.find('.zm-item-title a').text(),
description: `内容:${item.find('textarea').text()}`,
link: linkUrl
};
}).get(),
item:
list &&
list
.map((index, item) => {
item = $(item);
let linkUrl = item.find('link').attr('href');
if (linkUrl.startsWith('/')) {
linkUrl = 'https://www.zhihu.com' + linkUrl;
}
return {
title: item.find('.zm-item-title a').text(),
description: `内容:${item.find('textarea').text()}`,
link: linkUrl,
};
})
.get(),
};
};
+9 -11
View File
@@ -7,8 +7,8 @@ module.exports = async (ctx) => {
url: 'https://news-at.zhihu.com/api/2/news/latest', // 旧版api,可以获取文章的url。参考:https://github.com/izzyleung/ZhihuDailyPurify/wiki/%E7%9F%A5%E4%B9%8E%E6%97%A5%E6%8A%A5-API-%E5%88%86%E6%9E%90
headers: {
'User-Agent': config.ua,
'Referer': 'https://daily.zhihu.com' // 不知道应该写什么比较好,随便写一个吧
}
Referer: 'https://daily.zhihu.com', // 不知道应该写什么比较好,随便写一个吧
},
});
const d = new Date();
// todayfmt: YYYYMMDD
@@ -19,8 +19,8 @@ module.exports = async (ctx) => {
url: `https://news-at.zhihu.com/api/2/news/before/${todayfmt}`, // 旧版api,可以获取文章的url。参考:https://github.com/izzyleung/ZhihuDailyPurify/wiki/%E7%9F%A5%E4%B9%8E%E6%97%A5%E6%8A%A5-API-%E5%88%86%E6%9E%90
headers: {
'User-Agent': config.ua,
'Referer': 'https://daily.zhihu.com'
}
Referer: 'https://daily.zhihu.com',
},
});
const items = today.data.news.concat(yesterday.data.news);
@@ -29,12 +29,10 @@ module.exports = async (ctx) => {
title: '知乎日报',
link: 'https://daily.zhihu.com',
description: '每天3次,每次7分钟',
item: items.map((item) => {
return {
title: item.title,
description: `<img referrerpolicy="no-referrer" src='${item.image}'/>`, // 暂时没有找到包含正文的api,所以就放一张图吧
link: item.share_url
};
}),
item: items.map((item) => ({
title: item.title,
description: `<img referrerpolicy="no-referrer" src='${item.image}'/>`, // 暂时没有找到包含正文的api,所以就放一张图吧
link: item.share_url,
})),
};
};
+6 -6
View File
@@ -9,16 +9,16 @@ module.exports = async (ctx) => {
url: `https://zhuanlan.zhihu.com/api/columns/${id}/posts?limit=20`,
headers: {
'User-Agent': config.ua,
'Referer': `https://zhuanlan.zhihu.com/${id}`,
}
Referer: `https://zhuanlan.zhihu.com/${id}`,
},
});
const infoRes = await axios({
method: 'get',
url: `https://zhuanlan.zhihu.com/api/columns/${id}`,
headers: {
'User-Agent': config.ua,
'Referer': `https://zhuanlan.zhihu.com/${id}`,
}
Referer: `https://zhuanlan.zhihu.com/${id}`,
},
});
const list = listRes.data;
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
title: item.title,
description: item.content.replace(/<img src="/g, '<img referrerpolicy="no-referrer" src="https://pic4.zhimg.com/'),
pubDate: new Date(item.publishedTime).toUTCString(),
link: `https://zhuanlan.zhihu.com${item.url}`
link: `https://zhuanlan.zhihu.com${item.url}`,
})),
};
};
};
+22 -11
View File
@@ -14,20 +14,31 @@ module.exports = async (ctx) => {
url: `http://${domain}/list/ajax-get-data`,
headers: {
'User-Agent': config.ua,
'Referer': `http://${domain}/${city.toUpperCase()}/search.html`
Referer: `http://${domain}/${city.toUpperCase()}/search.html`,
},
data: qs.stringify({
'recent_money': 0,
'sort': 0,
'is_whole': iswhole,
'room': room,
'key_word': keyword,
'step': 0
recent_money: 0,
sort: 0,
is_whole: iswhole,
room: room,
key_word: keyword,
step: 0,
}),
});
let data = response.data.data; //当查询的结果不存在时,该 data 是个对象 { info: '数据加载完毕' }
//判断数据的类型,如果有数据就是数组类型的,没有数据的话,就赋值为空数组
data = (data instanceof Array) ? data : [{title:"我们找不到任何与您的搜索条件匹配的结果,但是调整您的搜索条件可能会有所帮助",room_name:"",list_img:"",city:"",id:""}];
let data = response.data.data; // 当查询的结果不存在时,该 data 是个对象 { info: '数据加载完毕' }
// 判断数据的类型,如果有数据就是数组类型的,没有数据的话,就赋值为空数组
data =
data instanceof Array
? data
: [
{
title: '我们找不到任何与您的搜索条件匹配的结果,但是调整您的搜索条件可能会有所帮助',
room_name: '',
list_img: '',
city: '',
id: '',
},
];
ctx.state.data = {
title: `自如的${keyword}${iswhole ? '整租' : '合租'}${room}室房源`,
@@ -36,7 +47,7 @@ module.exports = async (ctx) => {
item: data.map((item) => ({
title: item.title,
description: `${item.room_name}<img referrerpolicy="no-referrer" src="${item.list_img}">`,
link: `http://${domain}/${city.toUpperCase()}/room/${item.id}.html`
link: `http://${domain}/${city.toUpperCase()}/room/${item.id}.html`,
})),
};
};
+12 -7
View File
@@ -8,17 +8,22 @@ const logger = winston.createLogger({
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
new winston.transports.File({ filename: 'logs/combined.log' })
]
new winston.transports.File({
filename: 'logs/error.log',
level: 'error',
}),
new winston.transports.File({ filename: 'logs/combined.log' }),
],
});
//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
logger.add(new winston.transports.Console({
format: winston.format.simple()
}));
logger.add(
new winston.transports.Console({
format: winston.format.simple(),
})
);
module.exports = logger;
module.exports = logger;
+5 -2
View File
@@ -1,5 +1,8 @@
const crypto = require('crypto');
module.exports = function md5(date) {
return crypto.createHash('md5').update(date).digest("hex");
}
return crypto
.createHash('md5')
.update(date)
.digest('hex');
};
+4 -4
View File
@@ -1,5 +1,5 @@
module.exports = function wait(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
+16 -3
View File
@@ -2528,9 +2528,13 @@ https-browserify@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
iconv-lite@^0.4.17, iconv-lite@^0.4.4:
version "0.4.23"
resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
iconv-lite@0.4.19, iconv-lite@^0.4.17:
version "0.4.19"
resolved "http://registry.npm.taobao.org/iconv-lite/download/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
iconv-lite@^0.4.4:
version "0.4.21"
resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.21.tgz#c47f8733d02171189ebc4a400f3218d348094798"
dependencies:
safer-buffer ">= 2.1.2 < 3"
@@ -6151,3 +6155,12 @@ yallist@^2.1.2:
yallist@^3.0.0, yallist@^3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9"
yorkie@^1.0.3:
version "1.0.3"
resolved "http://registry.npm.taobao.org/yorkie/download/yorkie-1.0.3.tgz#5c05db48c012def99c29b79685b6ba2e40c8c671"
dependencies:
execa "^0.8.0"
is-ci "^1.0.10"
normalize-path "^1.0.0"
strip-indent "^2.0.0"