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 #50 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
14 changed files
with
226 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { data } = await got(`https://www.luxiangdong.com/content.json?t=${Date.now()}`); | ||
|
||
const items = data.posts.map((item) => ({ | ||
// 文章标题 | ||
title: item.title, | ||
// 文章链接 | ||
link: item.permalink, | ||
// 文章发布日期 | ||
pubDate: parseDate(item.date), | ||
// 如果有的话,文章作者 | ||
author: data.meta.author, | ||
// 如果有的话,文章分类 | ||
category: item.tags.map((tag) => tag.name), | ||
})); | ||
|
||
ctx.state.data = { | ||
// 源标题 | ||
title: '土猛的员外', | ||
// 源链接 | ||
link: 'https://www.luxiangdong.com/', | ||
// 源文章 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/archive': ['Levix'], | ||
}; |
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 = { | ||
'luxiangdong.com': { | ||
_name: '土猛的员外', | ||
'.': [ | ||
{ | ||
title: '文章', | ||
docs: 'https://docs.rsshub.app/routes/blog#luxiangdong', | ||
source: ['/'], | ||
target: '/luxiangdong/archive', | ||
}, | ||
], | ||
}, | ||
}; |
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 = (router) => { | ||
router.get('/archive', require('./archive')); | ||
}; |
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,36 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { baseUrl, parseList, parseItems } = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const requestPath = ctx.request.path; | ||
const isTopic = requestPath.startsWith('/topic/'); | ||
let link = baseUrl; | ||
|
||
if (isTopic) { | ||
link += `/topic/${ctx.params.id}`; | ||
} else if (requestPath === '/') { | ||
link += `/articles/report`; | ||
} else { | ||
link += `/articles${requestPath}`; | ||
} | ||
|
||
const { data: response } = await got(link); | ||
const $ = cheerio.load(response); | ||
|
||
const list = $(`${isTopic ? '.view-grouping' : '.pane-clone-of-article'} .views-row-inner`) | ||
.toArray() | ||
.map((item) => parseList($(item))); | ||
|
||
const items = await parseItems(list, ctx.cache.tryGet); | ||
|
||
ctx.state.data = { | ||
title: $('head title').text(), | ||
description: $('head meta[name="description"]').attr('content'), | ||
image: $('head meta[property="og:image"]').attr('content'), | ||
logo: $('head link[rel="shortcut icon"]').attr('href'), | ||
icon: $('head link[rel="shortcut icon"]').attr('href'), | ||
link, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
'': ['TonyRL'], | ||
'/': ['TonyRL'], | ||
'/:type?': ['TonyRL'], // /info and /report | ||
'/:type/:id+': ['TonyRL'], // /category/:id+ and /topic/:id | ||
'/category/:id+': ['TonyRL'], | ||
'/info': ['TonyRL'], | ||
'/report': ['TonyRL'], | ||
'/topic/:id': ['TonyRL'], | ||
}; |
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,31 @@ | ||
module.exports = { | ||
'tfc-taiwan.org.tw': { | ||
_name: '台灣事實查核中心', | ||
'.': [ | ||
{ | ||
title: '專題', | ||
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin', | ||
source: '/articles/category/:id+', | ||
target: '/tfc-taiwan/category/:id', | ||
}, | ||
{ | ||
title: '最新相關資訊', | ||
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin', | ||
source: ['/articles/info', '/'], | ||
target: '/tfc-taiwan/info', | ||
}, | ||
{ | ||
title: '最新查核報告', | ||
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin', | ||
source: ['/articles/report', '/'], | ||
target: '/tfc-taiwan/report', | ||
}, | ||
{ | ||
title: '重點專區', | ||
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin', | ||
source: '/topic/:id', | ||
target: '/tfc-taiwan/topic/:id', | ||
}, | ||
], | ||
}, | ||
}; |
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,7 @@ | ||
module.exports = (router) => { | ||
router.get('/', require('./index')); | ||
router.get('/category/:id+', require('./index')); | ||
router.get('/info', require('./index')); | ||
router.get('/report', require('./index')); | ||
router.get('/topic/:id', 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,7 @@ | ||
{{ if headerImage }} | ||
<img src="{{ headerImage }}"><br> | ||
{{ /if }} | ||
|
||
{{ if content }} | ||
{{@ content }} | ||
{{ /if }} |
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,56 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { join } = require('path'); | ||
const { art } = require('@/utils/render'); | ||
const asyncPool = require('tiny-async-pool'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const asyncPoolAll = async (...args) => { | ||
const results = []; | ||
for await (const result of asyncPool(...args)) { | ||
results.push(result); | ||
} | ||
return results; | ||
}; | ||
|
||
const baseUrl = 'https://tfc-taiwan.org.tw'; | ||
|
||
const parseList = (item) => { | ||
const a = item.find('.entity-list-title a'); | ||
return { | ||
title: a.text(), | ||
description: item.find('.entity-list-body').text(), | ||
link: new URL(a.attr('href'), baseUrl).href, | ||
pubDate: item.find('.post-date').length ? parseDate(item.find('.post-date').text(), 'YYYY-MM-DD') : undefined, | ||
image: item.find('.entity-list-img img').attr('src').split('?')[0], | ||
}; | ||
}; | ||
|
||
const parseItems = (list, tryGet) => | ||
asyncPoolAll(10, list, (item) => | ||
tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
|
||
$('.field-name-field-addthis, #fb-root, .fb-comments, .likecoin-embed, style[type="text/css"]').remove(); | ||
|
||
item.description = art(join(__dirname, 'templates/article.art'), { | ||
headerImage: item.image, | ||
content: $('#block-system-main .node-content').html(), | ||
}); | ||
|
||
item.pubDate = $('meta[property="article:published_time"]').attr('content'); | ||
item.updated = $('meta[property="article:modified_time"]').attr('content'); | ||
item.category = $('.node-tags .field-item') | ||
.toArray() | ||
.map((item) => $(item).text()); | ||
|
||
return item; | ||
}) | ||
); | ||
|
||
module.exports = { | ||
baseUrl, | ||
parseList, | ||
parseItems, | ||
}; |
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