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 #2051 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
5 changed files
with
181 additions
and
155 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,91 @@ | ||
import { Route, ViewType } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
|
||
export const route: Route = { | ||
path: '/district/:category?', | ||
name: '地方经济', | ||
url: 'district.ce.cn', | ||
maintainers: ['cscnk52'], | ||
handler, | ||
example: '/ce/district', | ||
parameters: { category: '栏目标识,默认为 roll(即时新闻)' }, | ||
description: `| 即时新闻 | 经济动态 | 独家视角 | 专题 | 数说地方 | 地方播报 | 专稿 | 港澳台 | | ||
|----------|----------|----------|------|----------|----------|------|--------| | ||
| roll | jjdt | poll | ch | ssdf | dfbb | zg | gat |`, | ||
categories: ['traditional-media'], | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
supportRadar: true, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['district.ce.cn/newarea/:category/index.shtml'], | ||
target: '/district/:category?', | ||
}, | ||
{ | ||
source: ['district.ce.cn/newarea/:category'], | ||
target: '/district/:category?', | ||
}, | ||
{ | ||
source: ['district.ce.cn'], | ||
target: '/district', | ||
}, | ||
], | ||
view: ViewType.Articles, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const rootUrl = 'http://district.ce.cn/'; | ||
const { category = 'roll' } = ctx.req.param(); | ||
const url = `${rootUrl}newarea/${category}/index.shtml`; | ||
const GB2312Response = await ofetch(url, { responseType: 'arrayBuffer' }); | ||
|
||
// originally site use gb2312 encoding | ||
const response = new TextDecoder('gb2312').decode(new Uint8Array(GB2312Response)); | ||
const $ = load(response); | ||
|
||
const bigTitle = $('div.channl a').eq(1).attr('title'); | ||
|
||
const list = $('div.sec_left li') | ||
.toArray() | ||
.map((e) => { | ||
const element = $(e); | ||
const title = element.find('a').text().trim(); | ||
const link = new URL(element.find('a').attr('href'), url).href; | ||
return { | ||
title, | ||
link, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const GB2312Response = await ofetch(item.link, { responseType: 'arrayBuffer' }); | ||
const response = new TextDecoder('gb2312').decode(new Uint8Array(GB2312Response)); | ||
const $ = load(response); | ||
|
||
const pubDateText = $('span#articleTime').text().trim(); | ||
item.pubDate = timezone(parseDate(pubDateText, 'YYYY年MM月DD日 HH:mm'), +8); | ||
|
||
item.description = $('div.TRS_Editor').html(); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: `中国经济网地方经济 - ${bigTitle}`, | ||
link: url, | ||
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,8 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '中国经济网', | ||
url: 'www.ce.cn', | ||
categories: ['traditional-media'], | ||
lang: 'zh-CN', | ||
}; |
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/news/:category?', | ||
categories: ['government'], | ||
example: '/whitehouse/news', | ||
parameters: { category: 'Category, see below, all by default' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['whitehouse.gov/:category', 'whitehouse.gov/'], | ||
target: '/news/:category', | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['nczitzk', 'hkamran80'], | ||
handler, | ||
description: `| All | Articles | Briefings and Statements | Presidential Actions | Remarks | | ||
| --- | -------- | ------------------------ | -------------------- | ------- | | ||
| | articles | briefings-statements | presidential-actions | remarks |`, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const category = ctx.req.param('category') ?? 'news'; | ||
|
||
const rootUrl = 'https://www.whitehouse.gov'; | ||
const currentUrl = `${rootUrl}/${category}/`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = load(response.data); | ||
|
||
const list = $('.post') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const a = item.find('a').first(); | ||
return { | ||
title: a.text(), | ||
link: a.attr('href'), | ||
pubDate: parseDate(item.find('time').attr('datetime')), | ||
category: [item.find('a[rel^=tag]').first().text()], | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const response = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
const $ = load(response.data); | ||
|
||
$('.wp-block-whitehouse-topper').remove(); | ||
item.description = $('.entry-content').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: $('title').text(), | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.