mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add Uber Engineering Blog (#11106)
* add Uber Engineering Blog * use more readable fulltext * use wp json api instead of original website scrapping,fix some mistakes according to the comments * try to mistaken modification of removing a newline at the end * Update docs/blog.md * Update docs/en/blog.md * Update lib/v2/uber/radar.js Co-authored-by: hulb <hulb@RD-NeoHu.netis.com.cn>
This commit is contained in:
@@ -332,6 +332,12 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
|
||||
|
||||
<Route author="junbaor SkiTiSu" example="/blogs/wangyin" path="/blogs/wangyin"/>
|
||||
|
||||
## 优步
|
||||
|
||||
### 工程技术
|
||||
|
||||
<Route author="hulb" example="/uber/blog" path="/uber/blog/:maxPage?" :paramsDesc="['获取的最多页数,默认最多获取第一页']" />
|
||||
|
||||
## 雨苁博客
|
||||
|
||||
### 首页
|
||||
|
||||
@@ -90,6 +90,12 @@ Limit the number of entries to be retrieved by adding `?limit=x` to the end of t
|
||||
|
||||
<RouteEn author="chazeon" example="/stratechery" path="/stratechery" />
|
||||
|
||||
## Uber
|
||||
|
||||
### Engineering
|
||||
|
||||
<RouteEn author="hulb" example="/uber/blog" path="/uber/blog/:maxPage?" :paramsDesc="['max number of pages to retrieve, default to 1 page at most']" />
|
||||
|
||||
## WordPress
|
||||
|
||||
### Blog
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootURL = 'https://www.uber.com';
|
||||
const apiURL = 'https://blogapi.uber.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let maxPage = Number(ctx.params.maxPage);
|
||||
if (Number.isNaN(maxPage)) {
|
||||
maxPage = 1;
|
||||
}
|
||||
|
||||
let pages = await Promise.all(
|
||||
[...Array(maxPage).keys()].map((pageIdx) =>
|
||||
got(`${apiURL}/wp-json/blog/v1/data`, {
|
||||
searchParams: {
|
||||
page: pageIdx + 1,
|
||||
parent: 'pittsburgh',
|
||||
slug: 'engineering',
|
||||
},
|
||||
})
|
||||
)
|
||||
);
|
||||
pages = pages.map((page) => page.data);
|
||||
|
||||
const result = await Promise.all(
|
||||
pages.map(
|
||||
async (page) =>
|
||||
await Promise.all(
|
||||
page.posts.map((post) =>
|
||||
ctx.cache.tryGet(`${rootURL}${post.link}`, async () => {
|
||||
let { data: article } = await got(`${apiURL}/wp-json/blog/v1/data`, {
|
||||
searchParams: {
|
||||
slug: post.link.replace(/\//g, '').replace('blog', ''),
|
||||
},
|
||||
});
|
||||
article = article.article;
|
||||
|
||||
return {
|
||||
title: article.title,
|
||||
description: article.content,
|
||||
pubDate: parseDate(article.created),
|
||||
author: article.author,
|
||||
category: article.categories.map((category) => category.category_name),
|
||||
};
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Uber Engineering Blog`,
|
||||
link: rootURL + '/blog/engineering',
|
||||
description: 'The technology behind Uber Engineering',
|
||||
item: result.flat(),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/blog/:maxPage?': ['hulb'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'uber.com': {
|
||||
_name: 'Uber Blog',
|
||||
www: [
|
||||
{
|
||||
title: 'Engineering',
|
||||
docs: 'https://docs.rsshub.app/blog.html#you-bu',
|
||||
source: ['/blog/pittsburgh/engineering'],
|
||||
target: '/uber/blog',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/blog/:maxPage?', require('./blog'));
|
||||
};
|
||||
Reference in New Issue
Block a user