Comparing version
23
index.js
@@ -1,2 +0,2 @@ | ||
const axios = require('axios').default; | ||
const axios = require('axios').default, c = require('cheerio'); | ||
const opt = { | ||
@@ -31,2 +31,20 @@ headers: { | ||
} | ||
async function get_character_amount(){ | ||
const res = await axios({url: 'https://www.animecharactersdatabase.com/charactershub.php?load=c_latest', method: 'get'}), $ = c.load(res.data); | ||
let number = 0; | ||
$('h3').each((idx, el) => { | ||
if(el.children[0].data){ | ||
if(el.children[0].data.toLowerCase().includes('characters')){ | ||
const new_number = parseInt(el.children[0].data.split(/ +/)[0]); | ||
number = new_number; | ||
} | ||
} | ||
}); | ||
return number; | ||
} | ||
async function get_random_character(){ | ||
const allIDs = await get_character_amount(), url = `http://www.animecharactersdatabase.com/api_series_characters.php?character_id=${Math.floor(Math.random() * allIDs)}`; | ||
const res = await axios({url: url, method: 'get', opt}); | ||
return res.data; | ||
} | ||
module.exports = { | ||
@@ -36,3 +54,4 @@ get_character_by_id, | ||
get_character_by_search, | ||
get_anime_by_search | ||
get_anime_by_search, | ||
get_random_character | ||
} |
{ | ||
"name": "acb-api", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "a api that uses the animecharacterdatabase and access information from there", | ||
@@ -21,4 +21,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
"axios": "^0.21.1", | ||
"cheerio": "^1.0.0-rc.5" | ||
} | ||
} |
@@ -127,2 +127,14 @@ # ACB Information Api | ||
} | ||
get_random_character returns: | ||
{ | ||
"id": 666, | ||
"anime_id": 90, | ||
"anime_image": "http://ami.animecharactersdatabase.com/productimages/90.jpg", | ||
"character_image": "http://ami.animecharactersdatabase.com/./images/maihime/Reito_thumb.jpg", | ||
"origin": "Mai-HiME - The Genealogical Tree of Fate", | ||
"gender": "Male", | ||
"name": "Reito Kanzaki", | ||
"desc": "Reito Kanzaki is a character from the visual novel Mai-HiME - The Genealogical Tree of Fate." | ||
} | ||
``` |
@@ -13,2 +13,5 @@ const a = require('./index'); | ||
console.log(res); | ||
}); | ||
a.get_random_character().then(res => { | ||
console.log(res); | ||
}); |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
8088
20.7%69
46.81%139
9.45%2
100%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added