Skip to content

Commit

Permalink
feat(route): add goldman sachs developer blog (#16527)
Browse files Browse the repository at this point in the history
* feat(route): add goldman sachs developer blog

* fix: change namespace

* fix: remove fixed user-agent
  • Loading branch information
chesha1 authored Aug 24, 2024
1 parent b24beaa commit 534da15
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
58 changes: 58 additions & 0 deletions lib/routes/gs/developer/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Route, Data } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';

export const route: Route = {
path: '/developer/blog',
categories: ['blog'],
example: '/gs/developer/blog',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['developer.gs.com/blog/posts'],
target: '/developer/blog',
},
],
name: 'Goldman Sachs Developer Blog',
zh: {
name: '高盛开发者博客',
},
maintainers: ['chesha1'],
handler: handlerRoute,
};

async function handlerRoute(): Promise<Data> {
const response = await ofetch('https://developer.gs.com/blog/posts');
const $ = load(response);

const items = $('div[data-cy="blog-card-grid"] a')
.toArray()
.map((item) => {
const link = 'https://developer.gs.com' + $(item).attr('href');
const title = $(item).find('span').eq(1).text();
const author = $(item).find('span').eq(2).text();
const description = $(item).find('span').eq(3).text();
const pubDate = $(item).find('span').eq(0).text();
return {
title,
link,
author,
description,
pubDate,
};
});

return {
title: 'Goldman Sachs Developer Blog',
link: 'https://developer.gs.com/blog/posts',
item: items,
};
}
9 changes: 9 additions & 0 deletions lib/routes/gs/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Goldman Sachs',
url: 'goldmansachs.com',
zh: {
name: '高盛',
},
};

0 comments on commit 534da15

Please sign in to comment.