feat(route): add google research blog (#16352)

This commit is contained in:
Zhiwei Li
2024-08-05 09:25:13 +08:00
committed by GitHub
parent 63e375b86f
commit d44ade21b6
+45
View File
@@ -0,0 +1,45 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const baseUrl = 'https://research.google';
export const route: Route = {
path: '/research',
categories: ['blog'],
example: '/google/research',
name: 'Research Blog',
maintainers: ['Levix'],
radar: [
{
source: ['research.google'],
},
],
handler: async () => {
const response = await ofetch(`${baseUrl}/blog`);
const $ = load(response);
const items = $('div.js-configurable-list .blog-posts-grid__cards .glue-grid__col')
.toArray()
.map((eleItem) => {
const item = $(eleItem);
const a = item.find('a').first();
return {
title: a.find('.headline-5').text(),
link: `${baseUrl}${a.attr('href')}`,
pubDate: parseDate(item.find('.glue-label.glue-spacer-1-bottom').text()),
author: 'Google',
category: item
.find('.not-glue.caption')
.toArray()
.map((item) => $(item).text().replace('·', '').trim()),
};
});
return {
title: 'Google Research Blog',
link: `${baseUrl}/blog`,
item: items,
};
},
};