Skip to content

Commit

Permalink
feat(route): add google research blog (DIYgod#16352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Levix authored and pull[bot] committed Oct 1, 2024
1 parent 364b840 commit 225118c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/routes/google/research.ts
Original file line number Diff line number Diff line change
@@ -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,
};
},
};

0 comments on commit 225118c

Please sign in to comment.