-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add goldman sachs developer blog (#16527)
* feat(route): add goldman sachs developer blog * fix: change namespace * fix: remove fixed user-agent
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 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
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, | ||
}; | ||
} |
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,9 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Goldman Sachs', | ||
url: 'goldmansachs.com', | ||
zh: { | ||
name: '高盛', | ||
}, | ||
}; |