DavideViolante / socialblade-com-api

Unofficial APIs for socialblade.com website.
MIT License
12 stars 7 forks source link

Fetching data: "Cannot read property 'data' of undefined" #41

Closed jorgeorejas closed 2 years ago

jorgeorejas commented 3 years ago

I'm not able to fetch the data from the api, It returns an error with the source even using 'twitter'. Hope you could help me

jorgeorejas commented 3 years ago

Update:

const { socialblade } = require('socialblade-com-api');

const api_key = '<my_key>';

const baseURL = `http://api.scraperapi.com?api_key=${api_key}&url=`;

async function instagramFollowers() {
  let participantsAndFollowers = [];

  console.log('getting data for Jorge Orejas');

  let response = await socialblade(baseURL, 'instagram', 'orejasjorge');

  participantsAndFollowers.push({
    response
  });
  await delay(1000);

  console.log(participantsAndFollowers);
}

instagramFollowers()
  .then(() => {
    console.log('all done');
  })
  .catch((err) => {
    console.log(err);
  });

After trying to use this code to fetch the data from my instagram account I get this error

getting fata for Jorge Orejas
TypeError: Cannot read property 'data' of undefined
    at getOutput (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/functions.js:30:43)
    at socialblade (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/index.js:27:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async instagramFollowers (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/utils/twitter.js:12:18) {stack: 'TypeError: Cannot read property 'data' of und…rojo/Dev/Adivias-SaaS/utils/twitter.js:12:18)', message: 'Cannot read property 'data' of undefined'}
No debugger available, can not send 'variables'
Failed once, retrying...
TypeError: Cannot read property 'data' of undefined
    at getOutput (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/functions.js:30:43)
    at socialblade (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/index.js:27:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async instagramFollowers (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/utils/twitter.js:12:18) {stack: 'TypeError: Cannot read property 'data' of und…rojo/Dev/Adivias-SaaS/utils/twitter.js:12:18)', message: 'Cannot read property 'data' of undefined'}
No debugger available, can not send 'variables'
Failed once, retrying...
TypeError: Cannot read property 'data' of undefined
    at getOutput (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/functions.js:30:43)
    at socialblade (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/node_modules/socialblade-com-api/index.js:27:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async instagramFollowers (/Users/jorgeorejasrojo/Dev/Adivias-SaaS/utils/twitter.js:12:18) {stack: 'TypeError: Cannot read property 'data' of und…rojo/Dev/Adivias-SaaS/utils/twitter.js:12:18)', message: 'Cannot read property 'data' of undefined'}
No debugger available, can not send 'variables'
Request failed too many times, aborting.
DavideViolante commented 3 years ago

Thank you for letting me know. Socialblade website has increased its anti scraping system and Scraperapi fails the request for the page. The actual page returned is the following:

socialblade


So at this time this repo is not working anymore. I will try to find a way or I will delete the repo altogether.

DavideViolante commented 2 years ago

I found out that this works again using Puppeteer, I released a new version.