commit
35be2d99a1
|
|
@ -504,4 +504,20 @@ key: 产品密钥
|
|||
|
||||
路由: `/biquge/novel/latestchapter/:id`
|
||||
|
||||
参数: id,小说 id,可在对应小说页 URL 中找到
|
||||
参数: id,小说 id,可在对应小说页 URL 中找到
|
||||
|
||||
## 开发者头条
|
||||
|
||||
### 今天头条
|
||||
|
||||
举例: [https://rss.now.sh/toutiao/today](https://rss.now.sh/toutiao/today)
|
||||
|
||||
路由: `/toutiao/today`
|
||||
|
||||
### 独家号
|
||||
|
||||
举例: [https://rss.now.sh/toutiao/user/140544](https://rss.now.sh/toutiao/user/140544)
|
||||
|
||||
路由: `/toutiao/user/:id`
|
||||
|
||||
参数: id,独家号 id,可在对应独家号页 URL 中找到
|
||||
|
|
|
|||
|
|
@ -87,4 +87,8 @@ router.get('/tucaoqq/post/:project/:key', require('./routes/tucaoqq/post'));
|
|||
// 笔趣阁
|
||||
router.get('/biquge/novel/latestchapter/:id', require('./routes/biquge/chapter'));
|
||||
|
||||
// 开发者头条
|
||||
router.get('/toutiao/today', require('./routes/toutiao/today'));
|
||||
router.get('/toutiao/user/:id', require('./routes/toutiao/user'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
const axios = require('axios');
|
||||
const template = require('../../utils/template');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('../../config');
|
||||
|
||||
const baseUrl = 'https://toutiao.io'
|
||||
module.exports = async (ctx)=>{
|
||||
const response = await axios({
|
||||
method:'get',
|
||||
url:baseUrl,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Host':'toutiao.io'
|
||||
},
|
||||
responseType: 'text'
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
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);
|
||||
const item = {
|
||||
title: article_el.find('a').eq(0).text(),
|
||||
link: baseUrl + article_el.find('a').eq(0).attr('href')
|
||||
};
|
||||
article_item.push(item);
|
||||
};
|
||||
ctx.body = template({
|
||||
title: '开发者头条:' + title,
|
||||
link: baseUrl,
|
||||
item: article_item,
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
const axios = require('axios');
|
||||
const template = require('../../utils/template');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('../../config');
|
||||
|
||||
const baseUrl = 'https://toutiao.io';
|
||||
module.exports = async (ctx)=>{
|
||||
const id = ctx.params.id;
|
||||
let requestUrl = `${baseUrl}/subjects/${id}?f=new`;
|
||||
const response = await axios({
|
||||
method:'get',
|
||||
url:requestUrl,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Host':'toutiao.io'
|
||||
},
|
||||
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 list = $('.posts>.post', '#main');
|
||||
const article_item = [];
|
||||
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')
|
||||
};
|
||||
article_item.push(item);
|
||||
};
|
||||
ctx.body = template({
|
||||
title: '开发者头条独家号:'+title,
|
||||
description:description,
|
||||
image: image,
|
||||
link: baseUrl,
|
||||
item: article_item,
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue