mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 12:21:31 +08:00
feat(route): add Shopping Design (#11575)
This commit is contained in:
@@ -178,6 +178,12 @@ Behance 用户主页 URL 获取用户名,如 <https://www.behance.net/mishapet
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## Shopping Design
|
||||||
|
|
||||||
|
### 文章列表
|
||||||
|
|
||||||
|
<Route author="miles170" example="/shoppingdesign/posts" path="/shoppingdesign/posts"/>
|
||||||
|
|
||||||
## UI 中国
|
## UI 中国
|
||||||
|
|
||||||
### 推荐文章
|
### 推荐文章
|
||||||
|
|||||||
3
lib/v2/shoppingdesign/maintainer.js
Normal file
3
lib/v2/shoppingdesign/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/posts': ['miles170'],
|
||||||
|
};
|
||||||
43
lib/v2/shoppingdesign/posts.js
Normal file
43
lib/v2/shoppingdesign/posts.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const asyncPool = require('tiny-async-pool');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
// sn_f parameter is required to prevent redirection
|
||||||
|
const currentUrl = 'https://www.shoppingdesign.com.tw/post?sn_f=1';
|
||||||
|
const response = await got(currentUrl);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const items = [];
|
||||||
|
// maximum parallel requests on the target website are limited to 11.
|
||||||
|
for await (const data of asyncPool(10, $('article-item'), (item) => {
|
||||||
|
item = $(item);
|
||||||
|
const link = item.attr('url');
|
||||||
|
return ctx.cache.tryGet(link, async () => {
|
||||||
|
const response = await got(`${link}?sn_f=1`);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const article = $('.left article .htmlview');
|
||||||
|
article.find('d-image').each(function () {
|
||||||
|
$(this).replaceWith(`<img src="${$(this).attr('lg')}">`);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: $('.left article .top_info h1').text(),
|
||||||
|
author: $('meta[name="my:author"]').attr('content'),
|
||||||
|
description: article.html(),
|
||||||
|
category: $('meta[name="my:category"]').attr('content'),
|
||||||
|
pubDate: parseDate($('meta[name="my:publish"]').attr('content')),
|
||||||
|
link,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})) {
|
||||||
|
items.push(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('meta[property="og:title"]').attr('content'),
|
||||||
|
link: currentUrl,
|
||||||
|
description: $('meta[property="og:description"]').attr('content'),
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
13
lib/v2/shoppingdesign/radar.js
Normal file
13
lib/v2/shoppingdesign/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'shoppingdesign.com.tw': {
|
||||||
|
_name: 'Shopping Design',
|
||||||
|
www: [
|
||||||
|
{
|
||||||
|
title: '文章列表',
|
||||||
|
docs: 'https://docs.rsshub.app/design.html#shopping-design',
|
||||||
|
source: '/post',
|
||||||
|
target: '/shoppingdesign/posts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/shoppingdesign/router.js
Normal file
3
lib/v2/shoppingdesign/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/posts', require('./posts'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user