mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 21:18:57 +08:00
add 「美拍用户动态」 (#1510)
用户动态 By @ihewro 举例: https://rsshub.app/meipai/user/56537299 路由: /meipai/user/:id 参数: id, 必选 - 用户 id, 可在 分享出去获得的用户主页 URL 中找到
This commit is contained in:
@@ -553,6 +553,10 @@ RSSHub 提供下列 API 接口:
|
|||||||
|
|
||||||
<route name="用户动态" author="DIYgod" example="/douyin/user/93610979153" path="/douyin/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
<route name="用户动态" author="DIYgod" example="/douyin/user/93610979153" path="/douyin/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
||||||
|
|
||||||
|
### 美拍
|
||||||
|
|
||||||
|
<route name="用户动态" author="ihewro" example="/meipai/user/56537299" path="/meipai/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
||||||
|
|
||||||
### 雪球
|
### 雪球
|
||||||
|
|
||||||
<route name="用户动态" author="imlonghao" example="/xueqiu/user/8152922548" path="/xueqiu/user/:id/:type?" :paramsDesc="['用户 id, 可在用户主页 URL 中找到', '动态的类型, 不填则默认全部']">
|
<route name="用户动态" author="imlonghao" example="/xueqiu/user/8152922548" path="/xueqiu/user/:id/:type?" :paramsDesc="['用户 id, 可在用户主页 URL 中找到', '动态的类型, 不填则默认全部']">
|
||||||
|
|||||||
@@ -1040,4 +1040,7 @@ router.get('/ebb', require('./routes/ebb'));
|
|||||||
// Indienova
|
// Indienova
|
||||||
router.get('/indienova/article', require('./routes/indienova/article'));
|
router.get('/indienova/article', require('./routes/indienova/article'));
|
||||||
|
|
||||||
|
// 美拍
|
||||||
|
router.get('/meipai/user/:uid', require('./routes/meipai/user'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
40
lib/routes/meipai/user.js
Normal file
40
lib/routes/meipai/user.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const util = require('./utils');
|
||||||
|
|
||||||
|
// const date = require('../../utils/date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const uid = ctx.params.uid;
|
||||||
|
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://www.meipai.com/user/${uid}`,
|
||||||
|
headers: {
|
||||||
|
Referer: 'https://www.meipai.com/',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML
|
||||||
|
const list = $('#mediasList')
|
||||||
|
.find('li')
|
||||||
|
.get();
|
||||||
|
const name = $('.feed-left .content-l-h2').text();
|
||||||
|
|
||||||
|
const result = await util.ProcessFeed(list, ctx.cache);
|
||||||
|
|
||||||
|
// 使用 cheerio 选择器,选择 class="note-list" 下的所有 "li"元素,返回 cheerio node 对象数组
|
||||||
|
// cheerio get() 方法将 cheerio node 对象数组转换为 node 对象数组
|
||||||
|
|
||||||
|
// 注:每一个 cheerio node 对应一个 HTML DOM
|
||||||
|
// 注:cheerio 选择器与 jquery 选择器几乎相同
|
||||||
|
// 参考 cheerio 文档:https://cheerio.js.org/
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${name}又有更新了`,
|
||||||
|
link: `https://www.meipai.com/user/${uid}/`,
|
||||||
|
description: `${name}`,
|
||||||
|
item: result,
|
||||||
|
};
|
||||||
|
};
|
||||||
35
lib/routes/meipai/utils.js
Normal file
35
lib/routes/meipai/utils.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const ProcessFeed = async (list) => {
|
||||||
|
const host = 'https://www.meipai.com';
|
||||||
|
|
||||||
|
return await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
|
||||||
|
const $title = $('.detail-cover-title');
|
||||||
|
const $desciption = $('.feed-description');
|
||||||
|
|
||||||
|
// 详情页面的地址(视频页面地址)
|
||||||
|
const itemUrl = url.resolve(host, $desciption.attr('href'));
|
||||||
|
|
||||||
|
// RSS内容(美拍提供了友好的网页版视频展示)
|
||||||
|
const imgSrc = $('.feed-v-wrap img').attr('src');
|
||||||
|
const text = $desciption.text() + `<a href="${itemUrl}"><img src="https:${imgSrc}" /></a>`;
|
||||||
|
|
||||||
|
// 列表上提取到的信息
|
||||||
|
return {
|
||||||
|
title: $title.text(),
|
||||||
|
description: text,
|
||||||
|
link: itemUrl,
|
||||||
|
author: $('.feed-name').text(),
|
||||||
|
guid: itemUrl,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
ProcessFeed,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user