feat: add router yahoo-jp-tv (Yahoo!テレビ) (#3928)
This commit is contained in:
parent
7eee7cdeb7
commit
f2bb385991
|
|
@ -243,6 +243,12 @@ pageClass: routes
|
|||
|
||||
<Route author="fallenhh" example="/soundcloud/tracks/angeart" path="/soundcloud/tracks/:user" :paramsDesc="['用户名']" />
|
||||
|
||||
## Yahoo!テレビ
|
||||
|
||||
### 番組検索
|
||||
|
||||
<Route author="sakamossan" example="/yahoo-jp-tv/%E8%8A%B1%E6%BE%A4%E9%A6%99%E8%8F%9C" path="/yahoo-jp-tv/:query" :paramsDesc="['搜索查询']"/>
|
||||
|
||||
## Youtube
|
||||
|
||||
见 [#youtube](/social-media.html#youtube)
|
||||
|
|
|
|||
|
|
@ -2110,6 +2110,9 @@ router.get('/rthk-news/:lang/:category', require('./routes/rthk-news/index'));
|
|||
// yahoo
|
||||
router.get('/yahoo-news/:region/:category?', require('./routes/yahoo-news/index'));
|
||||
|
||||
// Yahoo!テレビ
|
||||
router.get('/yahoo-jp-tv/:query', require('./routes/yahoo-jp-tv/index'));
|
||||
|
||||
// 白鲸出海
|
||||
router.get('/baijing', require('./routes/baijing'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const querystring = require('querystring');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const query = querystring.stringify({ q: ctx.params.query });
|
||||
const link = `https://tv.yahoo.co.jp/search/?${query}`;
|
||||
const response = await got(link);
|
||||
const $ = cheerio.load(response.body);
|
||||
const [title] = $('.search_result')
|
||||
.find('p')
|
||||
.text()
|
||||
.split(':');
|
||||
const item = $('.programlist li')
|
||||
.map((index, item) => {
|
||||
const $item = $(item);
|
||||
const title = `${$item
|
||||
.find('.leftarea')
|
||||
.text()
|
||||
.replace(/\n/g, '')} ${$item.find('.yjLS').text()}`;
|
||||
const link = `https://tv.yahoo.co.jp${$item.find('div.rightarea p.yjLS.pb5p a').attr('href')}`;
|
||||
const description = $item.find('p.yjMS:nth-child(3)').text();
|
||||
return { title, description, link };
|
||||
})
|
||||
.get();
|
||||
ctx.state.data = { title, link, item };
|
||||
};
|
||||
Loading…
Reference in New Issue