rsshub 1.0.0-master.c9ccd6b → 1.0.0-master.c9d8450

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/router.js CHANGED
@@ -3693,7 +3693,7 @@ router.get('/yinxiang/personal/:id', lazyloadRouteHandler('./routes/yinxiang/per
3693
3693
  router.get('/yinxiang/category/:id', lazyloadRouteHandler('./routes/yinxiang/category'));
3694
3694
 
3695
3695
  // 晚点LatePost
3696
- router.get('/latepost/:proma?', lazyloadRouteHandler('./routes/latepost/index'));
3696
+ // router.get('/latepost/:proma?', lazyloadRouteHandler('./routes/latepost/index'));
3697
3697
 
3698
3698
  // 西瓜视频
3699
3699
  router.get('/ixigua/user/video/:uid/:disableEmbed?', lazyloadRouteHandler('./routes/ixigua/userVideo'));
@@ -1,37 +1,25 @@
1
1
  const got = require('@/utils/got');
2
- const cheerio = require('cheerio');
2
+ const { JSDOM } = require('jsdom');
3
3
 
4
4
  module.exports = async (ctx) => {
5
5
  const team = ctx.params.team;
6
6
  const link = `https://www.dongqiudi.com/team/${team}.html`;
7
7
 
8
8
  const response = await got.get(link);
9
- const $ = cheerio.load(response.data);
10
- const teamName = $('h1.name').text();
11
- const list = $('table.schedule_list tr.stat_list');
12
- const out = [];
9
+ const dom = new JSDOM(response.data, {
10
+ runScripts: 'dangerously',
11
+ });
12
+ const data = dom.window.__NUXT__.data[0];
13
+ const resultData = data.teamScheduleData.filter((data) => data.fs_A && data.fs_B);
13
14
 
14
- for (let i = 0; i < list.length; i++) {
15
- const $ = cheerio.load(list[i]);
15
+ const teamName = data.teamDetail.base_info.team_name;
16
16
 
17
- const score = $('td:nth-of-type(5)').text().trim();
18
-
19
- if (score !== '-') {
20
- const time = $('td.match_time_hidden').text();
21
- const type = $('td.gameweek').text();
22
- const home = $('td:nth-of-type(4)').text().trim();
23
- const away = $('td:nth-of-type(6)').text().trim();
24
- const title = `${type} ${home} ${score} ${away}`;
25
-
26
- const single = {
27
- title,
28
- link,
29
- pubDate: new Date(time),
30
- guid: title,
31
- };
32
- out.push(single);
33
- }
34
- }
17
+ const out = resultData.map((result) => ({
18
+ title: `${result.match_title} ${result.team_A_name} ${result.fs_A}-${result.fs_B} ${result.team_B_name}`,
19
+ guid: result.match_id,
20
+ link: result.scheme.replace('dongqiudi:///game/', 'https://www.dongqiudi.com/liveDetail/'),
21
+ pubDate: result.start_time,
22
+ }));
35
23
 
36
24
  ctx.state.data = {
37
25
  title: `${teamName} 比赛结果`,
@@ -6,24 +6,16 @@ module.exports = async (ctx) => {
6
6
  const domain = 'http://wap.eastday.com';
7
7
 
8
8
  const response = await got({
9
- method: 'post',
10
- url: `https://apin.eastday.com/api/news/list`,
11
- json: {
12
- channelId: '15',
13
- currentPage: 1,
14
- pageSize: 20,
15
- appId: '190504',
16
- deviceId: '00000000',
17
- version: '0.0.0.2',
18
- },
9
+ method: 'get',
10
+ url: `https://apin.eastday.com/apiplus/special/specialnewslistbyurl?specialUrl=1632798465040016&skipCount=0&limitCount=20`,
19
11
  });
20
12
 
21
13
  const result = await Promise.all(
22
- response.data.list.map(async (item) => {
14
+ response.data.data.list.map(async (item) => {
23
15
  const link = item.url;
24
16
  const entity = {
25
17
  title: item.title,
26
- description: item.abstracts + '...',
18
+ description: item.abstracts,
27
19
  pubDate: new Date(item.time).toUTCString(),
28
20
  link,
29
21
  };
@@ -1,102 +1,100 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
- const url = require('url');
4
- const iconv = require('iconv-lite');
3
+ const { parseDate } = require('@/utils/parse-date');
5
4
 
6
- const urlRoot = 'http://www.jwc.sjtu.edu.cn/web/sjtu/';
7
-
8
- const transcode = (buffer) => {
9
- const data = iconv.decode(buffer, 'gb2312');
10
- return cheerio.load(data);
11
- };
5
+ const urlRoot = 'https://jwc.sjtu.edu.cn/xwtg';
12
6
 
13
7
  async function getFullArticle(link) {
14
- try {
15
- const response = await got({
16
- method: 'get',
17
- url: link,
18
- responseType: 'buffer',
19
- });
20
- const fullArtData = transcode(response.data);
21
- const fullArt = fullArtData('.main_r_co_fo').html();
22
- return fullArt;
23
- } catch (error) {
24
- return '<h1> 这条消息被 -1s 了 </h1>';
8
+ const response = await got(link);
9
+ const $ = cheerio.load(response.body);
10
+ const content = $('.content-con');
11
+ if (content.length === 0) {
12
+ return null;
25
13
  }
14
+ // resolve links of <img> and <a>
15
+ content.find('img').each((_, e) => {
16
+ const relativeLink = $(e).attr('src');
17
+ const absLink = new URL(relativeLink, urlRoot).href;
18
+ $(e).attr('src', absLink);
19
+ });
20
+ content.find('a').each((_, e) => {
21
+ const relativeLink = $(e).attr('href');
22
+ const absLink = new URL(relativeLink, urlRoot).href;
23
+ $(e).attr('href', absLink);
24
+ });
25
+ return content.html();
26
26
  }
27
27
 
28
28
  module.exports = async (ctx) => {
29
- const type = ctx.params.type || 'students';
29
+ const type = ctx.params.type ?? 'all';
30
30
  const config = {
31
- students: {
32
- link: '198076.htm',
33
- section: '面向学生的通知',
31
+ all: {
32
+ section: '通知通告',
33
+ link: '/tztg.htm',
34
34
  },
35
35
  news: {
36
- link: '198005.htm',
36
+ link: '/xwzx.htm',
37
37
  section: '新闻中心',
38
38
  },
39
39
  notice: {
40
- link: '198392.htm',
40
+ link: '/tztg.htm',
41
41
  section: '通知通告',
42
42
  },
43
43
  operation: {
44
- link: '198042.htm',
44
+ link: '/jxyx.htm',
45
45
  section: '教学运行',
46
46
  },
47
47
  affairs: {
48
- link: '198043.htm',
48
+ link: '/zcxw.htm',
49
49
  section: '注册学务',
50
50
  },
51
51
  yjb: {
52
- link: '198044.htm',
52
+ link: '/yjb.htm',
53
53
  section: '研究办',
54
54
  },
55
55
  jgb: {
56
- link: '198046.htm',
56
+ link: '/jgb.htm',
57
57
  section: '教改办',
58
58
  },
59
59
  zhb: {
60
- link: '198047.htm',
60
+ link: '/zhb.htm',
61
61
  section: '综合办',
62
62
  },
63
+ language: {
64
+ link: '/yywz.htm',
65
+ section: '语言文字',
66
+ },
63
67
  party: {
64
- link: '198097.htm',
68
+ link: '/ghyzb.htm',
65
69
  section: '工会与支部',
66
70
  },
71
+ ge: {
72
+ link: '/tsjy.htm',
73
+ section: '通识教育',
74
+ },
67
75
  };
68
76
 
69
- const sectionLink = url.resolve(urlRoot, config[type].link);
77
+ const sectionLink = urlRoot + config[type].link;
70
78
 
71
79
  const response = await got({
72
80
  method: 'get',
73
81
  url: sectionLink,
74
- responseType: 'buffer',
75
82
  });
76
83
 
77
- const $ = transcode(response.data);
84
+ const $ = cheerio.load(response.body);
78
85
 
79
86
  const out = await Promise.all(
80
- $('.main_r_xuxian')
81
- .find('tr')
82
- .slice(0, 10)
87
+ $('body > div.list-box > div.container > div > div.ny_right > div > div.ny_right_con > div > ul')
88
+ .find('li')
83
89
  .map(async (i, e) => {
84
- const title = $(e)
85
- .find('a')
86
- .text()
87
- .replace(/[\r\n]/g, ' ');
88
- const relativeLink = $(e).find('a').attr('href');
89
- const link = url.resolve(sectionLink, relativeLink);
90
- const date = new Date(
91
- $(e)
92
- .children('td')
93
- .eq(-1)
94
- .text()
95
- .match(/\d{4}-\d{2}-\d{2}/)[0]
96
- );
97
- const timeZone = 8;
98
- const serverOffset = date.getTimezoneOffset() / 60;
99
- const pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
90
+ const info = $(e).find('.wz');
91
+ const relativeLink = info.find('a').attr('href');
92
+ const link = new URL(relativeLink, sectionLink).href;
93
+ const title = info.find('a > h2').text();
94
+ const timeElement = $(e).find('.sj');
95
+ const day = timeElement.find('h2').text();
96
+ const yearAndMonth = timeElement.find('p').text();
97
+ const pubDate = parseDate(`${yearAndMonth}.${day}`, 'YYYY.MM.DD');
100
98
  const description = await ctx.cache.tryGet(link, () => getFullArticle(link));
101
99
  const single = {
102
100
  title,
@@ -0,0 +1,55 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const category = ctx.params.category ?? 'test';
7
+ const language = ctx.params.language ?? 'tc';
8
+ const keyword = ctx.params.keyword ?? '';
9
+
10
+ const rootUrl = 'https://www.consumer.org.hk';
11
+ const currentUrl = `${rootUrl}/${language}/free-article/free-article-${category}?category=free-article-${category}&q=${keyword}`;
12
+
13
+ const response = await got({
14
+ method: 'get',
15
+ url: currentUrl,
16
+ });
17
+
18
+ const $ = cheerio.load(response.data);
19
+
20
+ let items = $('.half-img-blk__title, .img-plate-blk__title')
21
+ .find('a')
22
+ .toArray()
23
+ .map((item) => {
24
+ item = $(item);
25
+
26
+ return {
27
+ title: item.text(),
28
+ link: `${rootUrl}${item.attr('href')}`,
29
+ pubDate: parseDate(item.parent().prev().find('li').first().text(), 'YYYY.MM'),
30
+ };
31
+ });
32
+
33
+ items = await Promise.all(
34
+ items.map((item) =>
35
+ ctx.cache.tryGet(item.link, async () => {
36
+ const detailResponse = await got({
37
+ method: 'get',
38
+ url: item.link,
39
+ });
40
+
41
+ const content = cheerio.load(detailResponse.data);
42
+
43
+ item.description = content('.ckec').html();
44
+
45
+ return item;
46
+ })
47
+ )
48
+ );
49
+
50
+ ctx.state.data = {
51
+ title: $('title').text(),
52
+ link: currentUrl,
53
+ item: items,
54
+ };
55
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:category?/:language?/:keyword?': ['nczitzk'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'consumer.org.hk': {
3
+ _name: '消费者委员会',
4
+ '.': [
5
+ {
6
+ title: '文章',
7
+ docs: 'https://docs.rsshub.app/new-media.html#xiao-fei-zhe-wei-yuan-hui-wen-zhang',
8
+ source: ['/'],
9
+ target: '/consumer/:category?/:language?/:keyword?',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:category?/:language?/:keyword?', require('./index'));
3
+ };
@@ -0,0 +1,115 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const path = require('path');
4
+ const { art } = require('@/utils/render');
5
+ const { parseDate } = require('@/utils/parse-date');
6
+
7
+ module.exports = async (ctx) => {
8
+ const id = ctx.params.id ?? '';
9
+ const what = ctx.params.what ?? '';
10
+ const needTorrents = /t|y/i.test(ctx.params.needTorrents ?? 'true');
11
+ const needImages = /t|y/i.test(ctx.params.needImages ?? 'true');
12
+
13
+ const rootUrl = 'https://e-hentai.org';
14
+ const currentUrl = `${rootUrl}/${id ? (what === 'search' ? `?${id}` : what === 'category' ? id : `${what}/${id}`) : what}`;
15
+
16
+ const response = await got({
17
+ method: 'get',
18
+ url: currentUrl,
19
+ });
20
+
21
+ const $ = cheerio.load(response.data);
22
+
23
+ $('.itd').parent().remove();
24
+
25
+ let items = $('table.gltc tbody tr')
26
+ .slice(1, ctx.query.limit ? parseInt(ctx.query.limit) + 1 : needImages ? 16 : 26)
27
+ .toArray()
28
+ .map((item) => {
29
+ item = $(item);
30
+
31
+ return {
32
+ title: item.find('div.glink').text(),
33
+ author: item.find('td.glhide div a').text(),
34
+ link: item.find('td.glname a').attr('href'),
35
+ pubDate: parseDate(item.find('div.ir').prev().text()),
36
+ category: item
37
+ .find('div.gt')
38
+ .toArray()
39
+ .map((tag) => $(tag).attr('title').replace(/^:/, '')),
40
+ description: needImages ? '' : `<img src="${item.find('div.glthumb div img').attr('data-src') ?? item.find('div.glthumb div img').attr('src')}">`,
41
+ enclosure_url: needTorrents ? (item.find('div.gldown a img[title="Show torrents"]').length > 0 ? item.find('.gldown a').attr('href') : undefined) : undefined,
42
+ };
43
+ });
44
+
45
+ items = await Promise.all(
46
+ items.map(async (item) => {
47
+ if (item.enclosure_url) {
48
+ let forms = '',
49
+ torrents = await ctx.cache.get(item.enclosure_url);
50
+
51
+ if (!torrents) {
52
+ const torrentResponse = await got({
53
+ method: 'get',
54
+ url: item.enclosure_url,
55
+ });
56
+
57
+ const torrent = cheerio.load(torrentResponse.data);
58
+
59
+ torrent('h1, input[name="torrent_info"]').remove();
60
+ forms = torrent('form').parent().html();
61
+
62
+ torrents = torrent('table tbody tr td a')
63
+ .toArray()
64
+ .map((t) => {
65
+ t = torrent(t);
66
+ return { link: t.attr('href'), title: t.text() };
67
+ });
68
+ ctx.cache.set(item.enclosure_url, torrents);
69
+ }
70
+ item.description += forms;
71
+ item.enclosure_url = torrents[0].link;
72
+ item.enclosure_type = 'application/x-bittorrent';
73
+ }
74
+
75
+ if (needImages) {
76
+ let images = await ctx.cache.get(item.link);
77
+
78
+ if (!images) {
79
+ const imageResponse = await got({
80
+ method: 'get',
81
+ url: item.link,
82
+ });
83
+
84
+ const content = cheerio.load(imageResponse.data);
85
+
86
+ images = await Promise.all(
87
+ content('.gdtm a')
88
+ .toArray()
89
+ .map((i) =>
90
+ ctx.cache.tryGet(content(i).attr('href'), async () => {
91
+ const imageResponse = await got({
92
+ method: 'get',
93
+ url: content(i).attr('href'),
94
+ });
95
+
96
+ const image = cheerio.load(imageResponse.data);
97
+
98
+ return image('#img').attr('src');
99
+ })
100
+ )
101
+ );
102
+ ctx.cache.set(item.link, images);
103
+ }
104
+ item.description += art(path.join(__dirname, 'templates/images.art'), { images });
105
+ }
106
+ return item;
107
+ })
108
+ );
109
+
110
+ ctx.state.data = {
111
+ title: `${id || what || 'Front Page'} - E-Hentai Galleries`,
112
+ link: currentUrl,
113
+ item: items,
114
+ };
115
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ '/category/:category?/:needTorrents?/:needImages?': ['nczitzk'],
3
+ '/tag/:tag?/:needTorrents?/:needImages?': ['nczitzk'],
4
+ '/search/:keyword?/:needTorrents?/:needImages?': ['nczitzk'],
5
+ };
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ 'e-hentai.org': {
3
+ _name: 'E-Hentai',
4
+ '.': [
5
+ {
6
+ title: '分类',
7
+ docs: 'https://docs.rsshub.app/multimedia.html#e-hentai-fen-lei',
8
+ source: ['/:category', '/'],
9
+ target: '/e-hentai/category/:category?',
10
+ },
11
+ {
12
+ title: '标签',
13
+ docs: 'https://docs.rsshub.app/multimedia.html#e-hentai-biao-qian',
14
+ source: ['/tag/:tag', '/'],
15
+ target: '/e-hentai/tag/:tag?',
16
+ },
17
+ {
18
+ title: '搜索',
19
+ docs: 'https://docs.rsshub.app/multimedia.html#e-hentai-sou-suo',
20
+ source: ['/:keyword', '/'],
21
+ target: '/e-hentai/search/:keyword?',
22
+ },
23
+ ],
24
+ },
25
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:what?/:id?/:needTorrents?/:needImages?', require('./index'));
3
+ };
@@ -0,0 +1,3 @@
1
+ {{ each images image }}
2
+ <div><img src="{{ image }}"></div>
3
+ {{ /each }}
@@ -28,7 +28,10 @@ module.exports = async (ctx) => {
28
28
  link: a.attr('href'),
29
29
  description: art(path.join(__dirname, 'templates/description.art'), {
30
30
  summary: item.find('.indexs').text(),
31
- image: item.find('img').attr('src'),
31
+ image: item
32
+ .find('img')
33
+ .attr('data-original')
34
+ .replace(/!square/, ''),
32
35
  }),
33
36
  };
34
37
  });
@@ -43,6 +46,8 @@ module.exports = async (ctx) => {
43
46
 
44
47
  const content = cheerio.load(detailResponse.data);
45
48
 
49
+ content('.wechat-hide').prev().nextAll().remove();
50
+
46
51
  item.description += content('.entry').html();
47
52
  item.author = content('.postinfo strong').text();
48
53
  item.pubDate = timezone(parseDate(detailResponse.data.match(/"pubDate": "(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})"/)[1]), +8);
@@ -0,0 +1,62 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+ const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
5
+
6
+ const titles = {
7
+ '': '最新报道',
8
+ 1: '晚点独家',
9
+ 2: '人物访谈',
10
+ 3: '晚点早知道',
11
+ 4: '长报道',
12
+ };
13
+
14
+ module.exports = async (ctx) => {
15
+ const proma = ctx.params.proma ?? '';
16
+
17
+ const rootUrl = 'https://www.latepost.com';
18
+ const currentUrl = `${rootUrl}/${proma ? 'site/index' : 'news/get-news-data'}`;
19
+
20
+ const response = await got({
21
+ method: 'post',
22
+ url: currentUrl,
23
+ page: 1,
24
+ programa: proma,
25
+ });
26
+
27
+ let items = response.data.data.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 25).map((item) => ({
28
+ title: item.title,
29
+ link: `${rootUrl}${item.detail_url}`,
30
+ category: item.label.map((l) => l.label),
31
+ }));
32
+
33
+ items = await Promise.all(
34
+ items.map((item) =>
35
+ ctx.cache.tryGet(item.link, async () => {
36
+ const detailResponse = await got({
37
+ method: 'get',
38
+ url: item.link,
39
+ });
40
+
41
+ const content = cheerio.load(detailResponse.data);
42
+
43
+ content('br').each(function () {
44
+ content(this).parent().remove();
45
+ });
46
+
47
+ const pubDate = content('.article-header-date').text();
48
+ item.pubDate = timezone(/月|日/.test(pubDate) ? parseDate((/年/.test(pubDate) ? pubDate : `${new Date().getFullYear()}-${pubDate}`).replace(/年|月/g, '-').replace(/日/g, '')) : parseRelativeDate(pubDate), +8);
49
+
50
+ item.description = content('#select-main').html();
51
+
52
+ return item;
53
+ })
54
+ )
55
+ );
56
+
57
+ ctx.state.data = {
58
+ title: `${titles[proma]} - 晚点`,
59
+ link: currentUrl,
60
+ item: items,
61
+ };
62
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:proma?': ['nczitzk'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'latepost.com': {
3
+ _name: '晚点 Latepost',
4
+ '.': [
5
+ {
6
+ title: '报道',
7
+ docs: 'https://docs.rsshub.app/new-media.html#wan-dian-latepost-bao-dao',
8
+ source: '/',
9
+ target: (params, url) => `/latepost/${new URL(url).searchParams.get('proma')}`,
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:proma?', require('./index'));
3
+ };
@@ -0,0 +1,43 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ const { rootUrl, mobileRootUrl } = require('./utils');
5
+
6
+ module.exports = async (ctx) => {
7
+ const id = ctx.params.id;
8
+
9
+ const currentUrl = `${rootUrl}/Comic/comicInfo/id/${id}`;
10
+ const mobileCurrentUrl = `${mobileRootUrl}/comic/index/id/${id}`;
11
+
12
+ const response = await got({
13
+ method: 'get',
14
+ url: mobileCurrentUrl,
15
+ });
16
+
17
+ const $ = cheerio.load(response.data);
18
+
19
+ const author = $('.author-wr')
20
+ .toArray()
21
+ .map((a) => $(a).text().trim())
22
+ .join(', ');
23
+
24
+ const items = $('.reverse .bottom-chapter-item .chapter-link')
25
+ .toArray()
26
+ .map((item) => {
27
+ item = $(item);
28
+
29
+ return {
30
+ author,
31
+ title: item.text(),
32
+ description: `<img src="${item.find('.cover-image').attr('src')}">`,
33
+ link: `${rootUrl}${item.attr('href').replace(/chapter/, 'ComicView')}`,
34
+ };
35
+ });
36
+
37
+ ctx.state.data = {
38
+ title: `${$('h1').text()} - 腾讯动漫`,
39
+ link: currentUrl,
40
+ item: items,
41
+ description: `<p>${$('.head-info-desc').text()}</p>`,
42
+ };
43
+ };
@@ -0,0 +1,20 @@
1
+ const { rootUrl, ProcessItems } = require('./utils');
2
+
3
+ module.exports = async (ctx) => {
4
+ const titles = {
5
+ mt: '月票榜',
6
+ rise: '飙升榜',
7
+ new: '新作榜',
8
+ pay: '畅销榜',
9
+ top: 'TOP100',
10
+ male: '男生榜',
11
+ female: '女生榜',
12
+ };
13
+
14
+ const type = ctx.params.type ?? 'mt';
15
+ const time = ctx.params.time ?? 'cur';
16
+
17
+ const currentUrl = `${rootUrl}/Rank/comicRank/type/${type}`;
18
+
19
+ ctx.state.data = await ProcessItems(ctx, currentUrl, time, titles[type]);
20
+ };
@@ -0,0 +1,9 @@
1
+ {{ if image !== '' }}
2
+ <img src="{{ image }}">
3
+ {{ /if }}
4
+ {{ if description !== '' }}
5
+ <p>{{ description }}</p>
6
+ {{ /if }}
7
+ {{ each chapters chapter }}
8
+ <div><img src="{{ chapter.image }}"/><a href="{{ chapter.link }}">{{ chapter.title }}</a></div>
9
+ {{/each}}
@@ -0,0 +1,71 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { art } = require('@/utils/render');
4
+ const path = require('path');
5
+
6
+ const rootUrl = 'https://ac.qq.com';
7
+ const mobileRootUrl = 'https://m.ac.qq.com';
8
+
9
+ module.exports = {
10
+ rootUrl,
11
+ mobileRootUrl,
12
+ ProcessItems: async (ctx, currentUrl, time, title) => {
13
+ const response = await got({
14
+ method: 'get',
15
+ url: currentUrl,
16
+ });
17
+
18
+ const $ = cheerio.load(response.data);
19
+
20
+ let items = $(`${time ? `.${time}-month-data ` : ''}.text-overflow`)
21
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30)
22
+ .toArray()
23
+ .map((item) => {
24
+ item = $(item);
25
+
26
+ return {
27
+ title: item.text(),
28
+ guid: `${rootUrl}${item.attr('href')}`,
29
+ link: `${mobileRootUrl}${item.attr('href').replace(/Comic\/ComicInfo/, 'comic/index')}`,
30
+ };
31
+ });
32
+
33
+ items = await Promise.all(
34
+ items.map((item) =>
35
+ ctx.cache.tryGet(item.guid, async () => {
36
+ const detailResponse = await got({
37
+ method: 'get',
38
+ url: item.link,
39
+ });
40
+
41
+ const content = cheerio.load(detailResponse.data);
42
+
43
+ item.link = item.guid;
44
+ item.author = content('.author-wr')
45
+ .toArray()
46
+ .map((a) => $(a).text().trim())
47
+ .join(', ');
48
+ item.description = art(path.join(__dirname, 'templates/description.art'), {
49
+ image: content('.head-cover')?.attr('src') ?? '',
50
+ description: content('.head-info-desc')?.text() ?? '',
51
+ chapters: content('.reverse .bottom-chapter-item .chapter-link')
52
+ .toArray()
53
+ .map((chapter) => ({
54
+ link: content(chapter).attr('href'),
55
+ title: content(chapter).find('.comic-title')?.text() ?? '',
56
+ image: content(chapter).find('.cover-image')?.attr('src') ?? '',
57
+ })),
58
+ });
59
+
60
+ return item;
61
+ })
62
+ )
63
+ );
64
+
65
+ return {
66
+ title: `${title} - 腾讯动漫`,
67
+ link: currentUrl,
68
+ item: items,
69
+ };
70
+ },
71
+ };
@@ -1,3 +1,5 @@
1
1
  module.exports = {
2
+ '/ac/comic/:id': ['nczitzk'],
3
+ '/ac/rank/:type?/:time?': ['nczitzk'],
2
4
  '/live/:id': ['nczitzk'],
3
5
  };
@@ -1,6 +1,20 @@
1
1
  module.exports = {
2
2
  'qq.com': {
3
3
  _name: '腾讯网',
4
+ ac: [
5
+ {
6
+ title: '排行榜',
7
+ docs: 'https://docs.rsshub.app/anime.html#teng-xun-dong-man-pai-hang-bang',
8
+ source: ['/Rank/comicRank/type/:type', '/'],
9
+ target: '/qq/ac/rank/:type?/:time?',
10
+ },
11
+ {
12
+ title: '漫画',
13
+ docs: 'https://docs.rsshub.app/anime.html#teng-xun-dong-man-man-hua',
14
+ source: ['/Comic/ComicInfo/id/:id', '/'],
15
+ target: '/qq/ac/comic/:id',
16
+ },
17
+ ],
4
18
  live: [
5
19
  {
6
20
  title: '企鹅直播',
@@ -1,3 +1,5 @@
1
1
  module.exports = function (router) {
2
+ router.get('/ac/comic/:id?', require('./ac/comic'));
3
+ router.get('/ac/rank/:type?/:time?', require('./ac/rank'));
2
4
  router.get('/live/:id', require('./live'));
3
5
  };
@@ -12,15 +12,10 @@ module.exports = async (ctx) => {
12
12
 
13
13
  const response = await got(apiUrl);
14
14
 
15
- if (response.data.items.length === 0) {
16
- throw Error('Empty feed');
17
- }
18
-
19
15
  let items = response.data.items.map((item) => ({
20
16
  title: item.title,
21
17
  pubDate: parseDate(item.date_modified),
22
18
  link: item.url,
23
- author: item.title,
24
19
  guid: item.id,
25
20
  }));
26
21
 
@@ -51,6 +46,18 @@ module.exports = async (ctx) => {
51
46
  desc: $('#js_content').html(),
52
47
  });
53
48
 
49
+ item.author = $('meta[name=author]').attr('content');
50
+
51
+ // another way to get publish timestamp:
52
+ // const publish_time_script = $('script[nonce][type="text/javascript"]:contains("var ct")').html();
53
+ // const publish_time_match = publish_time_script && publish_time_script.match(/var ct *= *"(\d{10})"/);
54
+ const publish_time_script = $('script[nonce][type="text/javascript"]:contains("publish_time")').html();
55
+ const publish_time_match = publish_time_script && publish_time_script.match(/var.*[ ,]n *= *"(\d{10})"/);
56
+ const publish_timestamp = publish_time_match && publish_time_match[1];
57
+ if (publish_timestamp) {
58
+ item.pubDate = parseDate(publish_timestamp * 1000);
59
+ }
60
+
54
61
  return item;
55
62
  })
56
63
  )
@@ -61,6 +68,7 @@ module.exports = async (ctx) => {
61
68
  link: response.data.feed_url,
62
69
  description: response.data.title,
63
70
  item: items,
71
+ allowEmpty: true,
64
72
  };
65
73
 
66
74
  ctx.state.json = {
@@ -1,3 +1,3 @@
1
1
  module.exports = {
2
- '/feeddd/:id': ['TonyRL'],
2
+ '/feeddd/:id': ['TonyRL', 'Rongronggg9'],
3
3
  };
@@ -0,0 +1,55 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const id = ctx.params.id ?? '';
7
+ const what = ctx.params.what ?? '';
8
+
9
+ const rootUrl = 'https://whoscall.com';
10
+ const currentUrl = `${rootUrl}/zh-hant/blog/${id ? `${what}/${id}` : 'articles'}`;
11
+
12
+ const response = await got({
13
+ method: 'get',
14
+ url: currentUrl,
15
+ });
16
+
17
+ const $ = cheerio.load(response.data);
18
+
19
+ const list = $('.post-card__title a')
20
+ .map((_, item) => {
21
+ item = $(item);
22
+
23
+ return {
24
+ title: item.text(),
25
+ link: `${rootUrl}${item.attr('href')}`,
26
+ };
27
+ })
28
+ .get();
29
+
30
+ const items = await Promise.all(
31
+ list.map((item) =>
32
+ ctx.cache.tryGet(item.link, async () => {
33
+ const detailResponse = await got({
34
+ method: 'get',
35
+ url: item.link,
36
+ });
37
+
38
+ const content = cheerio.load(detailResponse.data);
39
+
40
+ item.description = content('.blog-article__body').html();
41
+ item.pubDate = parseDate(detailResponse.data.match(/"datePublished":"(.*)","dateModified"/)[1]);
42
+
43
+ return item;
44
+ })
45
+ )
46
+ );
47
+
48
+ ctx.state.data = {
49
+ title: $('title')
50
+ .text()
51
+ .replace(/ - 第\d+頁/, ''),
52
+ link: currentUrl,
53
+ item: items,
54
+ };
55
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ '/': ['nczitzk'],
3
+ '/tags/:tag?': ['nczitzk'],
4
+ '/categories/:category?': ['nczitzk'],
5
+ };
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ 'whoscall.com': {
3
+ _name: 'Whoscall',
4
+ '.': [
5
+ {
6
+ title: '最新文章',
7
+ docs: 'https://docs.rsshub.app/blog.html#whoscall-zui-xin-wen-zhang',
8
+ source: ['/zh-hant/blog/articles', '/'],
9
+ target: '/whoscall',
10
+ },
11
+ {
12
+ title: '分類',
13
+ docs: 'https://docs.rsshub.app/blog.html#whoscall-fen-lei',
14
+ source: ['/zh-hant/blog/categories/:category', '/'],
15
+ target: '/whoscall/categories/:category?',
16
+ },
17
+ {
18
+ title: '標籤',
19
+ docs: 'https://docs.rsshub.app/blog.html#whoscall-biao-qian',
20
+ source: ['/zh-hant/blog/tags/:tag', '/'],
21
+ target: '/whoscall/tags/:tag?',
22
+ },
23
+ ],
24
+ },
25
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:what?/:id?', require('./index'));
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsshub",
3
- "version": "1.0.0-master.c9ccd6b",
3
+ "version": "1.0.0-master.c9d8450",
4
4
  "description": "Make RSS Great Again!",
5
5
  "main": "lib/pkg.js",
6
6
  "files": [
@@ -1,84 +0,0 @@
1
- const got = require('@/utils/got');
2
- const formatPubDate = require('@/utils/date');
3
- const cheerio = require('cheerio');
4
- const FormData = require('form-data');
5
-
6
- const titles = {
7
- '': '最新报道',
8
- 1: '晚点独家',
9
- 2: '人物访谈',
10
- 3: '晚点早知道',
11
- 4: '长报道',
12
- };
13
-
14
- const rootUrl = 'https://www.latepost.com';
15
-
16
- const dateAdapter = (date) => {
17
- const incompleteDate = ['今天', '昨天', '前天'];
18
- if (incompleteDate.indexOf(date) !== -1) {
19
- return `${date} 00:00`;
20
- } else {
21
- return date;
22
- }
23
- };
24
-
25
- module.exports = async (ctx) => {
26
- const proma = ctx.params.proma || '';
27
- const formData = new FormData();
28
- formData.append('page', 1);
29
- let data;
30
- if (proma === '') {
31
- const apiUrl = `${rootUrl}/site/index`;
32
- formData.append('limit', 9);
33
- const [first, response] = await Promise.all([
34
- got({ method: 'get', url: rootUrl }),
35
- got({
36
- method: 'post',
37
- url: apiUrl,
38
- body: formData,
39
- }),
40
- ]);
41
- const $ = cheerio.load(first.data);
42
- const firstItem = {};
43
- firstItem.title = $('.headlines-title a').text();
44
- firstItem.detail_url = $('.headlines-title a').attr('href');
45
- data = [firstItem].concat(response.data.data || []);
46
- } else {
47
- const apiUrl = `${rootUrl}/news/get-news-data`;
48
- formData.append('limit', 10);
49
- const response = await got({
50
- method: 'post',
51
- url: apiUrl,
52
- body: formData,
53
- });
54
- data = response.data.data;
55
- }
56
-
57
- const items = data.map((item) => ({
58
- title: item.title,
59
- description: item.abstract,
60
- link: `${rootUrl}${item.detail_url}`,
61
- }));
62
-
63
- ctx.state.data = {
64
- title: `晚点LatePost-${titles[proma]}`,
65
- link: rootUrl,
66
- item: await Promise.all(
67
- items.map((item) =>
68
- ctx.cache.tryGet(item.link, async () => {
69
- const res = await got({ method: 'get', url: item.link });
70
- // 优化排版
71
- const $ = cheerio.load(
72
- res.data
73
- .replace(/<p class="ql-align-justify"><br><\/p>/g, '')
74
- .replace(/<p class="ql-align-center"><br><\/p>/g, '')
75
- .replace(/<p><br><\/p>/g, '')
76
- );
77
- item.description = $('.article .abstract').html() + $('.article .article-body').html();
78
- item.pubDate = formatPubDate(dateAdapter($('.article-header-date').text()));
79
- return item;
80
- })
81
- )
82
- ),
83
- };
84
- };