1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

重写playlist爬取方法-01(调接口,而不是通过网易云音乐首页获取)

This commit is contained in:
程序员小墨 2022-11-09 16:15:48 +08:00
parent 6582bf8d40
commit b7fc10de63
4 changed files with 32 additions and 2 deletions

View File

@ -1,7 +1,6 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const requestUtils = require('../../../utils/requestUtils');
const sleepUtils = require('../../../utils/sleepUtils'); const sleepUtils = require('../../../utils/sleepUtils');
const dataManager = require('../dataManager'); const dataManager = require('../dataManager');

View File

@ -9,7 +9,7 @@ const dbUtils = global.dbUtils;
// refer: // refer:
// https://neteasecloudmusicapi-docs.4everland.app/ // https://neteasecloudmusicapi-docs.4everland.app/
// https://github.com/Binaryify/NeteaseCloudMusicApi // https://github.com/Binaryify/NeteaseCloudMusicApi
const { playlist_catlist, playlist_hot, playlist_detail } = require('NeteaseCloudMusicApi'); const { playlist_detail } = require('NeteaseCloudMusicApi');
const dataManager = require('../dataManager'); const dataManager = require('../dataManager');
async function fetchAll({ args }) { async function fetchAll({ args }) {

View File

@ -0,0 +1,29 @@
const fs = require('fs');
const path = require('path');
const sleepUtils = require('../../../utils/sleepUtils');
const dbUtils = global.dbUtils;
// refer:
// https://neteasecloudmusicapi-docs.4everland.app/
// https://github.com/Binaryify/NeteaseCloudMusicApi
const { top_playlist, top_playlist_highquality, related_playlist } = require('NeteaseCloudMusicApi');
// 获取歌词详情
async function fetch() {
try {
var result = await related_playlist({
id: 1
});
fs.writeFileSync(path.join(__dirname, "../../temp", `test.json`), JSON.stringify(result.body));
} catch (errors) {
console.error("error", errors);
await sleepUtils.sleep(10 * 1000);
}
console.log(result);
}
module.exports = {
fetch: fetch,
}

View File

@ -21,6 +21,7 @@ const commentUtils = require('./getInfo/commentUtils');
const playlistUtils = require('./getInfo/playlistUtils'); const playlistUtils = require('./getInfo/playlistUtils');
const assistantUtils = require('./assistantUtils'); const assistantUtils = require('./assistantUtils');
const testUtils = require('./getInfo/testUtils');
/** /**
* 测试 * 测试
@ -37,6 +38,7 @@ async function test() {
// let res = await artistInfoUtils.fetch({ artistId: "12023508" }); // let res = await artistInfoUtils.fetch({ artistId: "12023508" });
// let res = await songInfoUtils.fetch({ songId: "437608327" }); // let res = await songInfoUtils.fetch({ songId: "437608327" });
// let res = await playlistUtils.fetch({ playlistId: "4980157066", debug: true }); // let res = await playlistUtils.fetch({ playlistId: "4980157066", debug: true });
// let res = await testUtils.fetch();
// let res = await albumInfoUtils.getFromDatabase({ albumId: "9156" }); // let res = await albumInfoUtils.getFromDatabase({ albumId: "9156" });
// let res = await artistInfoUtils.getFromDatabase({ artistId: "12023508" }); // let res = await artistInfoUtils.getFromDatabase({ artistId: "12023508" });