forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1299 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
20 changed files
with
425 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
'/shopping-guide/:category?/:language?': ['TonyRL'], | ||
'/:category?/:language?/:keyword?': ['nczitzk'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = function (router) { | ||
router.get('/shopping-guide/:category?/:language?', require('./shopping-guide')); | ||
router.get('/:category?/:language?/:keyword?', require('./index')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { category = 'trivia', language = 'tc' } = ctx.params; | ||
const rootUrl = 'https://www.consumer.org.hk'; | ||
const currentUrl = `${rootUrl}/${language}/shopping-guide/${category}`; | ||
|
||
const { data: response } = await got(currentUrl, { | ||
headers: { | ||
cookie: `consumer_pagination={${encodeURI('"228c"')}:24}`, | ||
}, | ||
}); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
const list = $('.shadow-long-blk') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const info = item | ||
.find('.item-info li') | ||
.toArray() | ||
.map((item) => $(item).text().trim()); | ||
return { | ||
title: item.find('h2').text().trim(), | ||
description: item.find('p').text().trim(), | ||
link: `${rootUrl}${item.attr('href')}`, | ||
pubDate: parseDate(info.shift(), 'YYYY-MM-DD'), | ||
category: info, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
|
||
const header = $('.article-img-blk'); | ||
header.find('img').each((_, ele) => { | ||
ele = $(ele); | ||
if (ele.attr('src') && ele.attr('srcset')) { | ||
ele.removeAttr('srcset'); | ||
ele.attr('src', ele.attr('src').replace(/\/\d+c\d+\//, '/0p0/')); | ||
} | ||
}); | ||
|
||
item.description = header.html() + $('article .ckec').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: $('head title').text(), | ||
link: currentUrl, | ||
image: $('meta[property="og:image"]').attr('content'), | ||
logo: $('link[rel="apple-touch-icon"]').attr('href'), | ||
icon: $('link[rel="apple-touch-icon"]').attr('href'), | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id = 'sytzgg' } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; | ||
|
||
const rootUrl = 'http://www.jgjcndrc.org.cn'; | ||
const currentUrl = new URL(`list.aspx?clmId=${id}`, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
let items = $('ul.list_02 li.li a[title]') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
return { | ||
title: item.text(), | ||
link: new URL(item.prop('href'), rootUrl).href, | ||
pubDate: parseDate(item.prev().text()), | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: detailResponse } = await got(item.link); | ||
|
||
const content = cheerio.load(detailResponse); | ||
|
||
item.title = content('div.txt_title1').text(); | ||
item.description = content('div#zoom').html(); | ||
item.pubDate = parseDate(content('div.txt_subtitle1').text().trim()); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const author = $('title').text(); | ||
const subtitle = $('li.L').first().text(); | ||
const image = new URL($('img.logo2').prop('src'), rootUrl).href; | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: `${author} - ${subtitle}`, | ||
link: currentUrl, | ||
description: author, | ||
language: $('html').prop('lang'), | ||
image, | ||
subtitle, | ||
author, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/recent': ['Gnoyong'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'pkmer.cn': { | ||
_name: 'PKMer', | ||
'.': [ | ||
{ | ||
title: '最近更新', | ||
docs: 'https://docs.rsshub.app/routes/bbs#pkmer-zui-jin-geng-xin', | ||
source: ['/page/*'], | ||
target: '/pkmer/recent', | ||
}, | ||
], | ||
}, | ||
}; |
Oops, something went wrong.