'Cheerio Binance Leaderboard scrape
Hello I am trying to scrape some leaderboard postions from several traders.
Somehow I can catch all contents from tables all around the internet but not from this very Binance site, somehow I do not get any return. I dont even get a response how many table rows there are in this code snippet. Is something different with the table on the traders positons? I dont really know why I cant scrape this very data.
const axios = require("axios");
const cheerio = require("cheerio");
const express = require("express")
async function getTradeFeed() {
try {
const siteUrl = "https://www.binance.com/en/futures-activity/leaderboard?type=myProfile&encryptedUid=CCF3E0CB0AAD54D9D6B4CEC5E3E741D2"
const { data } = await axios({
method: "GET",
url: siteUrl,
})
const $ = cheerio.load(data)
const elemSelector = '#__APP > div > div:nth-child(2) > div.css-gnqbje > div.css-1bypc10 > div > div.css-2a3hpu > div > div > div > table > thead > tr'
$(elemSelector).each((parentIdx, parentElem) => {
console.log(parentIdx)
})
} catch (err) {
console.error(err)
}
}
getTradeFeed();
Solution 1:[1]
You can use this API.
This is a sample code that gets all positions from CCF3E0CB0AAD54D9D6B4CEC5E3E741D2 trader:
const axios = require("axios");
const options = {
method: 'GET',
url: 'https://binance-futures-leaderboard1.p.rapidapi.com/v1/getOtherPosition',
params: {encryptedUid: 'CCF3E0CB0AAD54D9D6B4CEC5E3E741D2', tradeType: 'PERPETUAL'},
headers: {
'X-RapidAPI-Host': 'binance-futures-leaderboard1.p.rapidapi.com',
'X-RapidAPI-Key': 'YOUR-API-KEY
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nunnito Nevermind |
