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 #618 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
11 changed files
with
126 additions
and
10 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
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,67 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
const gixBaseURL = 'https://gixnetwork.org'; | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category; | ||
|
||
let newsURL = gixBaseURL + '/news'; | ||
let feedTitle = 'UW GIX News - '; | ||
let listSelector = 'body > div.site > div.site-content > div.content-area > main.site-main > '; | ||
|
||
switch (category) { | ||
case 'blog': | ||
newsURL += '/blog/'; | ||
feedTitle += 'Blogs'; | ||
listSelector += 'div.blog-wrapper > section.blog-list > article'; | ||
break; | ||
case 'inthenews': | ||
newsURL += '/inthenews/'; | ||
feedTitle += 'In The News'; | ||
listSelector += 'div.news-wrapper > section.news-list > article'; | ||
break; | ||
} | ||
|
||
const response = await got(newsURL); | ||
|
||
const data = response.data; | ||
|
||
const $ = cheerio.load(data); | ||
|
||
const list = $(listSelector) | ||
.map((index, item) => { | ||
item = $(item); | ||
const content = item.find('header').find('h2').find('a'); | ||
const time = item.find('header').find('span.h4').text(); | ||
|
||
return { | ||
// title: content.text(), | ||
time, | ||
link: content.attr('href'), | ||
}; | ||
}) | ||
.get(); | ||
|
||
const itemContent = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const descriptionResponse = await got(item.link); | ||
|
||
const content = cheerio.load(descriptionResponse.data); | ||
|
||
item.title = content('header.entry-header').find('h1').text(); | ||
item.description = content('div.entry-content').html(); | ||
item.pubDate = Date.parse(item.time); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: feedTitle, | ||
link: newsURL, | ||
item: itemContent, | ||
}; | ||
}; |
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 = { | ||
'/gix/news/:category': ['dykderrick'], | ||
}; |
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 = { | ||
'gixnetwork.org': { | ||
_name: 'University of Washington', | ||
'.': [ | ||
{ | ||
title: 'Global Innovation Exchange News', | ||
docs: 'https://docs.rsshub.app/university.html#university-of-washington', | ||
source: ['/news/:category'], | ||
target: '/uw/gix/news/:category', | ||
}, | ||
], | ||
}, | ||
}; |
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 = function (router) { | ||
router.get('/gix/news/:category', require('./gix/news')); | ||
}; |
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
ef78d3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master.vercel.app
rsshub-master-auto-bot-ty.vercel.app
rsshub-master-git-master-auto-bot-ty.vercel.app