一些测试用的代码
This commit is contained in:
parent
dd9e72e16a
commit
a521758cfa
31
测试请求API接口.js
Normal file
31
测试请求API接口.js
Normal file
@ -0,0 +1,31 @@
|
||||
const request = require('request');
|
||||
|
||||
let url = 'https://api.bilibili.com/x/web-interface/ranking/v2?type=all';
|
||||
|
||||
// 请求 APi 接口
|
||||
async function getApiResult(url) {
|
||||
var return_data = await new Promise((resolve) => {
|
||||
request({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
}, (error, response, result) => {
|
||||
console.log("error, response, result", error, response, result);
|
||||
if (!error && (response.statusCode == 200)) {
|
||||
// 请求成功
|
||||
resolve(result);
|
||||
} else {
|
||||
// 请求失败
|
||||
console.log(`error is ${error}`);
|
||||
resolve("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
// console.log(`return_data is ${JSON.stringify(return_data)}`);
|
||||
return return_data;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let result = await getApiResult(url);
|
||||
console.log(result);
|
||||
}
|
||||
main();
|
42
验证B站排行榜的字段是否都显示出来.js
Normal file
42
验证B站排行榜的字段是否都显示出来.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user