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 #1341 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
44 changed files
with
1,145 additions
and
428 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 was deleted.
Oops, something went wrong.
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,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '共产党员网', | ||
url: 'www.12371.cn', | ||
categories: ['government'], | ||
}; |
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,64 @@ | ||
import got from '@/utils/got'; | ||
import * as cheerio from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import cache from '@/utils/cache'; | ||
|
||
import { Route } from '@/types'; | ||
|
||
const handler = async (ctx) => { | ||
const { category = 'zxfb' } = ctx.req.param(); | ||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 15; | ||
|
||
const rootUrl = 'https://www.12371.cn/'; | ||
const currentUrl = `${rootUrl}${category}/`; | ||
const response = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const pattern = /item=(\[{.*?}]);/; | ||
const newsList = JSON.parse($('script[language="javascript"]').text().match(pattern)?.[1].replaceAll("'", '"') || '[]'); | ||
|
||
const topNewsList = newsList.slice(0, limit).map((item) => ({ | ||
title: item.title, | ||
pubDate: timezone(parseDate(item.brief, 'YYYY-MM-DD HH:mm:ss'), 8), | ||
link: item.link_add, | ||
})); | ||
|
||
const items = await Promise.all( | ||
topNewsList.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const detailResponse = await got(item.link); | ||
const $ = cheerio.load(detailResponse.data); | ||
|
||
item.description = $('.word').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: $('title').text(), | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; | ||
|
||
export const route: Route = { | ||
path: '/:category?', | ||
example: '/12371/zxfb', | ||
parameters: { category: '新闻分类名,预设 `zxfb`' }, | ||
radar: [ | ||
{ | ||
source: ['www.12371.cn/:category'], | ||
}, | ||
], | ||
name: '最新发布', | ||
maintainers: ['zvrr'], | ||
handler, | ||
url: 'www.12371.cn', | ||
description: `| 最新发布 | | ||
| :------: | | ||
| zxfb |`, | ||
}; |
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '51CTO', | ||
url: '51cto.com', | ||
}; |
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,52 @@ | ||
import { Route } from '@/types'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import got from '@/utils/got'; | ||
import { getToken, sign } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/index/recommend', | ||
categories: ['programming'], | ||
example: '/51cto/index/recommend', | ||
radar: [ | ||
{ | ||
source: ['51cto.com/'], | ||
}, | ||
], | ||
name: '推荐', | ||
maintainers: ['cnkmmk'], | ||
handler, | ||
url: '51cto.com/', | ||
}; | ||
|
||
async function handler(ctx) { | ||
const url = 'https://api-media.51cto.com'; | ||
const requestPath = 'index/index/recommend'; | ||
const token = (await getToken()) as string; | ||
const timestamp = Date.now(); | ||
const params = { | ||
page: 1, | ||
page_size: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50, | ||
limit_time: 0, | ||
name_en: '', | ||
}; | ||
const response = await got(`${url}/${requestPath}`, { | ||
searchParams: { | ||
...params, | ||
timestamp, | ||
token, | ||
sign: sign(requestPath, params, timestamp, token), | ||
}, | ||
}); | ||
const list = response.data.data.data.list; | ||
return { | ||
title: '51CTO', | ||
link: 'https://www.51cto.com/', | ||
description: '51cto - 推荐', | ||
item: list.map((item) => ({ | ||
title: item.title, | ||
link: item.url, | ||
pubDate: parseDate(item.pubdate, +8), | ||
description: item.abstract, | ||
})), | ||
}; | ||
} |
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,21 @@ | ||
import ofetch from '@/utils/ofetch'; | ||
import cache from '@/utils/cache'; | ||
import md5 from '@/utils/md5'; | ||
|
||
export const getToken = () => | ||
cache.tryGet( | ||
'51cto:token', | ||
async () => { | ||
const response = await ofetch('https://api-media.51cto.com/api/token-get'); | ||
return response.data.data.token; | ||
}, | ||
3600, | ||
false | ||
); | ||
|
||
export const sign = (requestPath: string, payload: Record<string, any> = {}, timestamp: number, token: string) => { | ||
payload.timestamp = timestamp; | ||
payload.token = token; | ||
const sortedParams = Object.keys(payload).sort(); | ||
return md5(md5(requestPath) + md5(sortedParams + md5(token) + timestamp)); | ||
}; |
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,46 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/launchpool', | ||
categories: ['finance'], | ||
example: '/binance/launchpool', | ||
radar: [ | ||
{ | ||
source: ['binance.com/:lang/support/announcement'], | ||
}, | ||
], | ||
name: 'Binance数字货币及交易对上新', | ||
maintainers: ['zhenlohuang'], | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const baseUrl = 'https://www.binance.com/zh-CN/support/announcement'; | ||
const url = `${baseUrl}/数字货币及交易对上新?c=48&navId=48`; | ||
|
||
const response = await got({ | ||
url, | ||
headers: { | ||
Referer: 'https://www.binance.com/', | ||
}, | ||
}); | ||
|
||
const $ = load(response.data); | ||
const appData = JSON.parse($('#__APP_DATA').text()); | ||
const articles = appData.appState.loader.dataByRouteId.d969.catalogs.find((catalog) => catalog.catalogId === 48).articles.filter((article) => article.title.includes('币安新币挖矿上线')); | ||
|
||
return { | ||
title: 'Binance | 数字货币及交易对上新', | ||
link: url, | ||
description: '数字货币及交易对上新', | ||
item: articles.map((item) => ({ | ||
title: item.title, | ||
link: `${baseUrl}/${item.code}`, | ||
description: item.title, | ||
pubDate: parseDate(item.releaseDate), | ||
})), | ||
}; | ||
} |
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Binance', | ||
url: 'binance.com', | ||
}; |
Oops, something went wrong.