好友
阅读权限10
听众
最后登录1970-1-1
|
火云邪神
发表于 2024-10-8 21:01
25吾爱币
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const axios = require("axios");
const cheerio = require("cheerio");
async
function kuGeCi(query) {
let response = await axios.default.get("https://www.kugeci.com/search?q=" + encodeURIComponent(query));
const $ = cheerio.load(response.data || "")
const elements = $("#tablesort>tbody>tr");
if (elements.length === 0) {
return [];
}
let result = elements.map((i, el) => {
return {
title: $(el).find("tr>td:nth-child(2) a").text(),
id: $(el).find("tr>td:nth-child(2) a").attr("href"),
artist: $(el).find("tr>td:nth-child(3) a").text(),
}
}).get();
return result;
}
async
function search(query, page, type) {
if (type !== 'lyric') {
return;
}
query = query.replace(/(.*)\..*/, "$1");
let artist = "";
let title = "";
if (query.includes("-")) {
[artist, title] = query.split(/\s*-\s*/).map(i => i.trim());
} else {
title = query;
}
return {
isEnd: true,
data: await kuGeCi(title),
}
}
async
function getLyric(musicItem) {
let response = await axios.default.get(musicItem.id)
return {
rawLrc: cheerio.load(response.data)("#lyricsContainer").text()
}
}
module.exports = {
platform: "酷歌词",
author: 'QQ频道@LY+',
version: "0.0.0",
cacheControl: "no-store",
supportedSearchType: ['lyric'],
search,
getLyric
} |
最佳答案
查看完整内容
跑了一下
结果:
[mw_shl_code=text,true]➜ node index.js
[
{
title: '七里香 ',
id: 'https://www.kugeci.com/song/cFebEDIr',
artist: '周杰伦'
},
{
...
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|