feat: 爱奇艺分类中添加用户主页路由 (#2792)
This commit is contained in:
parent
1191d7fc49
commit
f58ef7d8a8
|
|
@ -152,6 +152,10 @@ pageClass: routes
|
|||
|
||||
## 爱奇艺
|
||||
|
||||
### 用户视频
|
||||
|
||||
<Route author="talengu" example="/iqiyi/user/video/2289191062" path="/iqiyi/user/video/:uid" :paramsDesc="['用户名']" />
|
||||
|
||||
### 动漫
|
||||
|
||||
<Route author="ranpox" example="/iqiyi/dongman/a_19rrh1sifx" path="/iqiyi/dongman/:id" :paramsDesc="['动漫 id, 可在该动漫主页 URL 中找到(不包括`.html`)']"/>
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ router.get('/qdaily/:type/:id', require('./routes/qdaily/index'));
|
|||
|
||||
// 爱奇艺
|
||||
router.get('/iqiyi/dongman/:id', require('./routes/iqiyi/dongman'));
|
||||
router.get('/iqiyi/user/video/:uid', require('./routes/iqiyi/video'));
|
||||
|
||||
// 南方周末
|
||||
router.get('/infzm/:id', require('./routes/infzm/news'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
// /iqiyi/user/video/:uid
|
||||
// http://localhost:1200/iqiyi/user/video/2289191062
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `http://www.iqiyi.com/u/${uid}/v`,
|
||||
headers: {
|
||||
Host: 'www.iqiyi.com',
|
||||
Referer: `http://www.iqiyi.com/u/${uid}/v`,
|
||||
},
|
||||
responseType: 'document',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const description = '';
|
||||
|
||||
const list = $('li[j-delegate="colitem"]');
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: `http://www.iqiyi.com/u/${uid}/v`,
|
||||
description: description,
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
const title = $(item)
|
||||
.find('.site-piclist_pic a')
|
||||
.attr('data-title');
|
||||
|
||||
return {
|
||||
title,
|
||||
description: `<img referrerpolicy="no-referrer" src="${$(item)
|
||||
.find('.site-piclist_pic img')
|
||||
.attr('src')}">`,
|
||||
pubDate: new Date(
|
||||
$(item)
|
||||
.find('.playTimes_status.tl')
|
||||
.text()
|
||||
.substring(0, 10)
|
||||
.replace(/-/g, '/')
|
||||
).toUTCString(),
|
||||
link: $(item)
|
||||
.find('.site-piclist_pic a')
|
||||
.attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
// .reverse(),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue