diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 48f435368f..6bf8043e7a 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -337,3 +337,13 @@ category 对应的关键词有 | 资讯 | 风景 | 体验 | 交通 | + +## 连线 Wired + +非订阅用户每月有阅读全文次数限制。 + +### 标签 + + + + diff --git a/lib/router.js b/lib/router.js index 13c1e0fa5a..29378c10f7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1319,6 +1319,9 @@ router.get('/curseforge/:gameid/:catagoryid/:projectid/files', require('./routes // 西南财经大学 router.get('/swufe/seie/:type?', require('./routes/universities/swufe/seie')); +// Wired +router.get('/wired/tag/:tag', require('./routes/wired/tag')); + // 语雀文档 router.get('/yuque/doc/:repo_id', require('./routes/yuque/doc')); diff --git a/lib/routes/wired/tag.js b/lib/routes/wired/tag.js new file mode 100644 index 0000000000..d229f35f70 --- /dev/null +++ b/lib/routes/wired/tag.js @@ -0,0 +1,39 @@ +const axios = require('@/utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `https://www.wired.com/tag/${ctx.params.tag}/page`; + + const response = await axios({ + method: 'get', + url, + }); + + const $ = cheerio.load(response.data); + const list = $('.archive-list-component__items li'); + + const posts = list + .map((index_, content_) => ({ + title: $(content_) + .find('.archive-item-component__title') + .text(), + description: ` +
+ ${$(content_) + .find('.archive-item-component__desc') + .text()}`, + link: `https://www.wired.com${$(content_) + .find('.archive-item-component__link') + .attr('href')}`, + })) + .get(); + + ctx.state.data = { + title: `Wired - ${ctx.params.tag}`, + link: url, + item: posts, + }; +};