diff --git a/docs/anime.md b/docs/anime.md index 79fd80ebf5..06bfe87542 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -249,6 +249,12 @@ pageClass: routes +## 紳士漫畫 + +### 最新 + + + ## 鼠绘漫画 ### 鼠绘漫画 @@ -266,9 +272,3 @@ pageClass: routes ### 最新汉化 - -## 紳士漫畫 - -### 最新 - - diff --git a/docs/finance.md b/docs/finance.md index 7908eca69c..3902b3a531 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -10,6 +10,16 @@ pageClass: routes +## WEEX 华尔街见闻旗下全球投资线上品牌 + +### 资讯 + + + +| 最新文章 | 市场要闻 | 交易策略 | 机构观点 | 投资学堂 | 行业观察 | 基金理财 | 分析师投稿 | +| -------- | -------- | -------- | -------- | -------- | -------- | -------- | ---------- | +| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | + ## 淘股吧股票论坛 ### 论坛总版 @@ -20,6 +30,12 @@ pageClass: routes +## 天天基金 + +### 用户动态 + + + ## 雪球 ### 用户动态 @@ -57,9 +73,3 @@ pageClass: routes | announcement | news | research | - -## 天天基金 - -### 用户动态 - - diff --git a/docs/new-media.md b/docs/new-media.md index cd416236ac..9513d70564 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -195,6 +195,10 @@ pageClass: routes | ---- | ------ | ---- | -------- | ---- | ---- | ---- | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +### 用户文章 + + + ## Quanta Magazine ### 全部 diff --git a/docs/other.md b/docs/other.md index f939a0126b..0e88ef3532 100644 --- a/docs/other.md +++ b/docs/other.md @@ -284,6 +284,12 @@ type 为 all 时,category 参数不支持 cost 和 free +## 酷安 + +### 图文-编辑精选 + + + ## 快递 100 ### 快递订单追踪 @@ -601,9 +607,3 @@ type 为 all 时,category 参数不支持 cost 和 free ### はてな匿名ダイアリー - 人気記事アーカイブ - -## 酷安 - -### 图文-编辑精选 - - diff --git a/docs/university.md b/docs/university.md index 9ee9e19689..ff7d573bd6 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1136,7 +1136,6 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet | 综合新闻 | zhxw | | 珞珈影像 | ljyx | | 学术动态 | kydt | -| 点击排行 | djpx | | 珞珈副刊 | ljfk | | 校史钩沉 | xsgc | | 来稿选登 | lgxd | diff --git a/lib/router.js b/lib/router.js index 25b6443b1a..958d40cd9c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -225,6 +225,9 @@ router.get('/jiemian/list/:cid', require('./routes/jiemian/list.js')); // 好奇心日报 router.get('/qdaily/:type/:id', require('./routes/qdaily/index')); +// WEEX +router.get('/weexcn/news/:typeid', require('./routes/weexcn/index')); + // 爱奇艺 router.get('/iqiyi/dongman/:id', require('./routes/iqiyi/dongman')); router.get('/iqiyi/user/video/:uid', require('./routes/iqiyi/video')); @@ -1088,6 +1091,7 @@ router.get('/36kr/newsflashes', require('./routes/36kr/newsflashes')); // PMCAFF router.get('/pmcaff/list/:typeid', require('./routes/pmcaff/list')); router.get('/pmcaff/feed/:typeid', require('./routes/pmcaff/feed')); +router.get('/pmcaff/user/:userid', require('./routes/pmcaff/user')); // icourse163 router.get('/icourse163/newest', require('./routes/icourse163/newest')); diff --git a/lib/routes/pmcaff/user.js b/lib/routes/pmcaff/user.js new file mode 100644 index 0000000000..7b5f794f57 --- /dev/null +++ b/lib/routes/pmcaff/user.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); + +// 样例 链接 : https://www.pmcaff.com/user/profile/Oak7mqnEQJ +const baseUrl = 'https://www.pmcaff.com/user/profile/'; +const api_url = 'https://api.pmcaff.com/api/v0/user/user-articles/'; + +const sizeTitle = 'PMCAFF互联网产品社区'; + +// 参考 feed.js + +module.exports = async (ctx) => { + // 默认 用户 id Oak7mqnEQJ + const userid = ctx.params.userid || 'Oak7mqnEQJ'; + const user_article = api_url + userid; + + // 直接获取到 json 数据 + const response = await got({ + method: 'get', + url: user_article, + headers: { + Referer: baseUrl, + }, + }); + + let user_name = ''; + + const result = []; + response.data.data.map(async (item) => { + const title = item.title; + const guid = item.article_id; + const pubDate = new Date(item.ctime).toUTCString(); + + const link = item.target_url; + const description = item.content; + + const single = { + title: title, + link: link, + guid: guid, + pubDate: pubDate, + description: description, + }; + + // 更新用户名 + user_name = item.user_profile.name; + + result.push(single); + }); + + ctx.state.data = { + title: user_name + '---' + sizeTitle, + link: baseUrl + userid, + description: 'PMCAFF互联网产品社区 - 产品经理人气组织::专注于互联网产品研究', + item: result, + }; +}; diff --git a/lib/routes/universities/whu/news.js b/lib/routes/universities/whu/news.js index 5accec2736..168d2ad1e6 100644 --- a/lib/routes/universities/whu/news.js +++ b/lib/routes/universities/whu/news.js @@ -1,10 +1,11 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +// const url = require('url'); // 参考 bit/jwc 北京理工大学的的页面写成 const baseUrl = 'https://news.whu.edu.cn/'; -const sizeTitle = '武汉大学新闻网'; +const sizeTitle = '--武汉大学新闻网'; const catrgoryMap = { wdyw: '武大要闻', @@ -20,7 +21,6 @@ const catrgoryMap = { zhxw: '综合新闻', ljyx: '珞珈影像', kydt: '学术动态', - djpx: '点击排行', ljfk: '珞珈副刊', xsgc: '校史钩沉', lgxd: '来稿选登', @@ -28,8 +28,28 @@ const catrgoryMap = { // 专门定义一个function用于加载文章内容 async function load(link) { - // 异步请求文章 - const response = await got.get(link); + let description = ''; + let pubDate = ''; + + let response; + // 如果不是 武汉大学的站点, 直接返回简单的标题即可 + // 判断 是否外站链接,如果是 则直接返回页面 不做单独的解析 + const https_reg = new RegExp('https://news.whu.edu.cn(.*)'); + if (!https_reg.test(link)) { + return { description }; + } + + // 外部链接访问不到不处理, 校内页面访问不到 记录错误 + try { + // 异步请求文章 + response = await got.get(link); + } catch (err) { + // 如果网络问题 直接出错 + if (err.name && (err.name === 'HTTPError' || err.name === 'RequestError')) { + description = 'Page 404 Please Check!'; + } + return { description }; + } // 加载文章内容 const $ = cheerio.load(response.data); @@ -37,10 +57,12 @@ async function load(link) { const date_txt = $('div.news_attrib') .text() .match(/[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/); // 匹配 yyyy-mm-dd hh:MM 格式时间 - const pubDate = new Date(date_txt[0]); + + // console.log(link,":",date_txt); + pubDate = new Date(date_txt[0]); // 提取文章内容 - const description = $('div.v_news_content').html(); + description = $('div.v_news_content').html(); // 返回解析的结果 return { description, pubDate }; } @@ -68,14 +90,25 @@ module.exports = async (ctx) => { .map(async (item) => { const $ = cheerio.load(list[item]); // 将列表项加载成 html const $rel_url = $('div.infotitle>a').attr('href'); // 获取 每一项的url - const $item_url = baseUrl + $rel_url; // 获取绝对路径 + // 判断是否相对链接 然后改写绝对路径 http 默认 否则加上基础路径 + const https_reg = new RegExp('^(?:[a-z]+:)?//'); + const $item_url = https_reg.test($rel_url) ? $rel_url : baseUrl + $rel_url; const $title = $('div>a').attr('title'); // 获取每个的标题 + const $pubdate = new Date( + $('div.infodate') + .text() + .trim() + // .match('/[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s/')[0] + ); + + // console.log(item, ":", $item_url,":",$pubdate); + // 列表上提取到的信息 // 标题 链接 const single = { title: $title, - // pubDate: $pubdate, + pubDate: $pubdate, link: $item_url, guid: $item_url, }; diff --git a/lib/routes/weexcn/index.js b/lib/routes/weexcn/index.js new file mode 100644 index 0000000000..63515948a0 --- /dev/null +++ b/lib/routes/weexcn/index.js @@ -0,0 +1,69 @@ +const got = require('@/utils/got'); + +// 样例 链接 : https://weexcn.com/news/newest +const baseUrl = 'https://weexcn.com/news/'; +// const api_url = 'https://api.jianyuweb.com/apiv1/content/articles?category=&limit=15&cursor=&platform=weex-platform'; + +const sizeTitle = 'WEEX--华尔街见闻旗下全球投资线上品牌'; + +// 数字标识, name 栏目名称, link: url, category: api cate +const map = new Map([ + ['1', { name: '最新文章', link: 'newest', category: '' }], + ['2', { name: '市场要闻', link: 'important', category: 'weex-important' }], + ['3', { name: '交易策略', link: 'strategy', category: 'weex-tradingstrategies' }], + ['4', { name: '机构观点', link: 'opinion', category: 'weex-institutioncomments' }], + ['5', { name: '投资学堂', link: 'education', category: 'weex-introduction' }], + ['6', { name: '行业观察', link: 'industry', category: 'weex-industryanalysis' }], + ['7', { name: '基金理财', link: 'money', category: 'weex-money' }], + ['7', { name: '分析师投稿', link: 'analyst', category: 'weex-analyst' }], +]); + +module.exports = async (ctx) => { + // 默认 用户 id Oak7mqnEQJ + const type_id = ctx.params.typeid || '1'; + const type = map.get(type_id); + + const type_url = 'https://weexcn.com/news/' + type.link; + const type_api_url = `https://api.jianyuweb.com/apiv1/content/articles?category=${type.category}&limit=15&cursor=&platform=weex-platform`; + + // 直接获取到 json 数据 + const response = await got({ + method: 'get', + url: type_api_url, + headers: { + Referer: type_url, + }, + }); + + const json_data = response.data.data.items; + + const result = []; + json_data.map(async (item) => { + const title = item.title; + const guid = item.id; + const pubDate = new Date(item.display_time * 1000).toUTCString(); + + // link 需要转换 + // https://wallstreetcn.com/articles/3587433 + // https://weexcn.com/articles/3587433 + const link = item.uri.replace(/wallstreetcn.com/, 'weexcn.com'); + const description = item.content_short; + + const single = { + title: title, + link: link, + guid: guid, + pubDate: pubDate, + description: description, + }; + + result.push(single); + }); + + ctx.state.data = { + title: type.name + '---' + sizeTitle, + link: baseUrl + type.link, + description: sizeTitle, + item: result, + }; +}; diff --git a/yarn.lock b/yarn.lock index f99d5e8f91..deceb64c47 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12738,4 +12738,4 @@ yorkie@2.0.0: zepto@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/zepto/-/zepto-1.2.0.tgz#e127bd9e66fd846be5eab48c1394882f7c0e4f98" - integrity sha1-4Se9nmb9hGvl6rSME5SIL3wOT5g= + integrity sha1-4Se9nmb9hGvl6rSME5SIL3wOT5g= \ No newline at end of file