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.
- Loading branch information
1 parent
ae2e068
commit 9bb55fd
Showing
2 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '守望先锋国服官方网站新闻', | ||
url: 'ow.blizzard.cn/news', | ||
lang: 'zh-CN', | ||
}; |
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,71 @@ | ||
import { Route } from '@/types'; | ||
import { load } from 'cheerio'; | ||
import cache from '@/utils/cache'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/news', | ||
categories: ['game'], | ||
example: '/overwatch-cn/news', | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['ow.blizzard.cn', 'ow.blizzard.cn/news'], | ||
target: '/news', | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['zhangpeng2k'], | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const rootUrl = `https://ow.blizzard.cn/news`; | ||
|
||
const response = await ofetch(rootUrl); | ||
const $ = load(response); | ||
|
||
const list = $('.list-data-container .list-item-container') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const title = item.find('.content-title').text(); | ||
const link = item.find('.fill-link').attr('href'); | ||
const description = item.find('.content-intro').text(); | ||
const pubDate = parseDate(item.find('.content-date').text()); | ||
const image = item.find('.item-pic').attr('src'); | ||
|
||
return { | ||
title, | ||
link, | ||
description, | ||
image, | ||
pubDate, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const response = await ofetch(item.link); | ||
const $ = load(response); | ||
item.description = $('.detail-content-box').first().html(); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: `守望先锋官方网站新闻`, | ||
link: `https://ow.blizzard.cn/news`, | ||
item: items, | ||
}; | ||
}; |