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 branch 'DIYgod/master' into cnki
* DIYgod/master: feat(route): add route UK Parliament Commons Library research by topic (DIYgod#16941) feat(route): add route UK Parliament Lords Library research by topic (DIYgod#16933) fix(route): change url in `/tvb/news` (DIYgod#17098) chore(deps): bump @hono/node-server from 1.13.1 to 1.13.2 (DIYgod#17088) chore(deps): bump @scalar/hono-api-reference from 0.5.152 to 0.5.153 (DIYgod#17085) chore(deps-dev): bump @babel/preset-env from 7.25.7 to 7.25.8 (DIYgod#17087) feat(route): also support podcast id in xiaoyuzhou fix: catch Invalid Date (DIYgod#17081) chore(deps): bump undici from 6.19.8 to 6.20.0 (DIYgod#17058) # Conflicts: # lib/routes/xiaoyuzhou/podcast.ts
- Loading branch information
Showing
7 changed files
with
481 additions
and
536 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,55 @@ | ||
import { load } from 'cheerio'; | ||
import { Route } from '@/types'; | ||
import puppeteer from '@/utils/puppeteer'; | ||
import timezone from '@/utils/timezone'; | ||
|
||
export const route: Route = { | ||
path: '/commonslibrary/type/:topic?', | ||
categories: ['government'], | ||
example: '/parliament.uk/commonslibrary/type/research-briefing', | ||
parameters: { topic: 'research by topic, string, example: [research-briefing|data-dashboard]' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: true, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'Commonlibrary', | ||
maintainers: ['AntiKnot'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { topic } = ctx.req.param(); | ||
const baseUrl = 'https://commonslibrary.parliament.uk/type'; | ||
const url = `${baseUrl}/${topic}/`; | ||
const browser = await puppeteer(); | ||
const page = await browser.newPage(); | ||
await page.setRequestInterception(true); | ||
page.on('request', (request) => { | ||
request.resourceType() === 'document' ? request.continue() : request.abort(); | ||
}); | ||
await page.goto(url, { | ||
waitUntil: 'domcontentloaded', | ||
}); | ||
|
||
const html = await page.evaluate(() => document.documentElement.innerHTML); | ||
await page.close(); | ||
const $ = load(html); | ||
const items = $('article.card--horizontal') | ||
.map((_, article) => ({ | ||
title: $(article).find('.card__text a').text().trim(), | ||
link: $(article).find('.card__text a').attr('href'), | ||
description: $(article).find('p').last().text().trim(), | ||
pubDate: timezone($(article).find('.card__date time').attr('datetime')), | ||
})) | ||
.toArray(); | ||
browser.close(); | ||
return { | ||
title: `parliament - lordslibrary - ${topic}`, | ||
link: baseUrl, | ||
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,55 @@ | ||
import { load } from 'cheerio'; | ||
import { Route } from '@/types'; | ||
import puppeteer from '@/utils/puppeteer'; | ||
import timezone from '@/utils/timezone'; | ||
|
||
export const route: Route = { | ||
path: '/lordslibrary/type/:topic?', | ||
categories: ['government'], | ||
example: '/parliament.uk/lordslibrary/type/research-briefing', | ||
parameters: { topic: 'research by topic, string, example: [research-briefing|buisness|economy]' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: true, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'House of Lords Library', | ||
maintainers: ['AntiKnot'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { topic } = ctx.req.param(); | ||
const baseUrl = 'https://lordslibrary.parliament.uk/type'; | ||
const url = `${baseUrl}/${topic}/`; | ||
const browser = await puppeteer(); | ||
const page = await browser.newPage(); | ||
await page.setRequestInterception(true); | ||
page.on('request', (request) => { | ||
request.resourceType() === 'document' ? request.continue() : request.abort(); | ||
}); | ||
await page.goto(url, { | ||
waitUntil: 'domcontentloaded', | ||
}); | ||
|
||
const html = await page.evaluate(() => document.documentElement.innerHTML); | ||
await page.close(); | ||
const $ = load(html); | ||
const items = $('article.card--horizontal') | ||
.map((_, article) => ({ | ||
title: $(article).find('.card__text a').text().trim(), | ||
link: $(article).find('.card__text a').attr('href'), | ||
description: $(article).find('p').last().text().trim(), | ||
pubDate: timezone($(article).find('.card__date time').attr('datetime')), | ||
})) | ||
.toArray(); | ||
browser.close(); | ||
return { | ||
title: `parliament - lordslibrary - ${topic}`, | ||
link: baseUrl, | ||
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'UK Parliament', | ||
url: 'parliament.uk', | ||
}; |
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
Oops, something went wrong.