fix(route/parliament.uk): page link and items selector (#17129)
* chore(route): add nytimes popular routes * fix(route/parliament.uk): fix return link * fix(route/parliament.uk): fix items selector ---------
This commit is contained in:
@@ -23,8 +23,8 @@ export const route: Route = {
|
||||
|
||||
async function handler(ctx) {
|
||||
const { topic } = ctx.req.param();
|
||||
const baseUrl = 'https://commonslibrary.parliament.uk/type';
|
||||
const url = `${baseUrl}/${topic}/`;
|
||||
const baseUrl = 'https://commonslibrary.parliament.uk';
|
||||
const url = `${baseUrl}/type/${topic}/`;
|
||||
const browser = await puppeteer();
|
||||
const page = await browser.newPage();
|
||||
await page.setRequestInterception(true);
|
||||
@@ -38,7 +38,7 @@ async function handler(ctx) {
|
||||
const html = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
await page.close();
|
||||
const $ = load(html);
|
||||
const items = $('article.card--horizontal')
|
||||
const items = $('div.l-box.l-box--no-border.card__text')
|
||||
.map((_, article) => ({
|
||||
title: $(article).find('.card__text a').text().trim(),
|
||||
link: $(article).find('.card__text a').attr('href'),
|
||||
@@ -49,7 +49,7 @@ async function handler(ctx) {
|
||||
browser.close();
|
||||
return {
|
||||
title: `parliament - lordslibrary - ${topic}`,
|
||||
link: baseUrl,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export const route: Route = {
|
||||
|
||||
async function handler(ctx) {
|
||||
const { topic } = ctx.req.param();
|
||||
const baseUrl = 'https://lordslibrary.parliament.uk/type';
|
||||
const url = `${baseUrl}/${topic}/`;
|
||||
const baseUrl = 'https://lordslibrary.parliament.uk';
|
||||
const url = `${baseUrl}/type/${topic}/`;
|
||||
const browser = await puppeteer();
|
||||
const page = await browser.newPage();
|
||||
await page.setRequestInterception(true);
|
||||
@@ -38,7 +38,7 @@ async function handler(ctx) {
|
||||
const html = await page.evaluate(() => document.documentElement.innerHTML);
|
||||
await page.close();
|
||||
const $ = load(html);
|
||||
const items = $('article.card--horizontal')
|
||||
const items = $('div.l-box.l-box--no-border.card__text')
|
||||
.map((_, article) => ({
|
||||
title: $(article).find('.card__text a').text().trim(),
|
||||
link: $(article).find('.card__text a').attr('href'),
|
||||
@@ -49,7 +49,7 @@ async function handler(ctx) {
|
||||
browser.close();
|
||||
return {
|
||||
title: `parliament - lordslibrary - ${topic}`,
|
||||
link: baseUrl,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user