mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
@@ -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'));
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user