TypeError: Cannot convert undefined or null to object #3

Closed
opened 2020-01-27 19:54:57 +01:00 by Androz2091 · 2 comments

Hello, I'm getting the following error when I run the code below:

const Insta = require("@kaki87/ig-scraper");
const InstaClient = new Insta();
// The following line throws the error
InstaClient.subscribeUserPosts('cyanidehappinessvf2').subscribe({
    next: shortcode => {
        console.log(shortcode);
    },
    error: err => {
        console.error(err);
    }
});

It says that the error comes from the index.js, line 44. I updated the code like this (I added a console.log):

When it works

I used a VPN to make the code working again, here is the console.log(data); result:

{
  logging_page_id: 'profilePage_10498164959',
  show_suggested_profiles: false,
  show_follow_dialog: false,
  graphql: {
    user: {
      biography: '• Cyanide & Happiness VF
' +
        '• Compte Français Officiel de @explosmofficial
' +
        '( ._.) ( I_ I) | •_•) ( •__•)
' +
        '• Compte tenu par Banzai et Tino.',
      blocked_by_viewer: false,
      country_block: false,
      external_url: 'http://explosm.net/',
      external_url_linkshimmed: 'https://l.instagram.com/?u=http%3A%2F%2Fexplosm.net%2F&e=ATP6iwEee5ljZhUxLDvGA_BetWfzVVaL83v4EXbeeoBnZpwIk59J0KyWAgVWfYDHbmZpf3Fw',
      edge_followed_by: [Object],
      followed_by_viewer: false,
      edge_follow: [Object],
      follows_viewer: false,
      full_name: 'Cyanide & Happiness ????????',
      has_channel: false,
      has_blocked_viewer: false,
      highlight_reel_count: 21,
      has_requested_viewer: false,
      id: '10498164959',
      is_business_account: false,
      is_joined_recently: false,
      business_category_name: null,
      is_private: false,
      is_verified: false,
      edge_mutual_followed_by: [Object],
      profile_pic_url: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-19/s150x150/61484002_337325923611511_3151014486266085376_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com&_nc_ohc=emGC-lnlKXMAX8VvkqC&oh=3c8b2319e920822e1d5ae55f13001a37&oe=5ECB1ECC',
      profile_pic_url_hd: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-19/s320x320/61484002_337325923611511_3151014486266085376_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com&_nc_ohc=emGC-lnlKXMAX8VvkqC&oh=248dab515ef0e093fe81faf22c548542&oe=5ED14E3C',
      requested_by_viewer: false,
      username: 'cyanidehappinessvf2',
      connected_fb_page: null,
      edge_felix_video_timeline: [Object],
      edge_owner_to_timeline_media: [Object],
      edge_saved_media: [Object],
      edge_media_collections: [Object]
    }
  },
  toast_content_on_load: null
}

When it throws the error

After removing my VPN, here is the result:

{
  captcha: { enabled: false, key: '' },
  gdpr_required: true,
  tos_version: 'eu',
  username_hint: ''
}

If you need further information, I'm available and I can make tests for you, if you cannot reproduce the bug.

Hello, I'm getting the following error when I run the code below: ![](https://i.goopics.net/5yL9X.png) ```js const Insta = require("@kaki87/ig-scraper"); const InstaClient = new Insta(); // The following line throws the error InstaClient.subscribeUserPosts('cyanidehappinessvf2').subscribe({ next: shortcode => { console.log(shortcode); }, error: err => { console.error(err); } }); ``` It says that the error comes from the `index.js`, line 44. I updated the code like this (I added a console.log): ![](https://i.goopics.net/QJDg3.png) ### When it works I used a VPN to make the code working again, here is the `console.log(data);` result: ```js { logging_page_id: 'profilePage_10498164959', show_suggested_profiles: false, show_follow_dialog: false, graphql: { user: { biography: '• Cyanide & Happiness VF ' + '• Compte Français Officiel de @explosmofficial ' + '( ._.) ( I_ I) | •_•) ( •__•) ' + '• Compte tenu par Banzai et Tino.', blocked_by_viewer: false, country_block: false, external_url: 'http://explosm.net/', external_url_linkshimmed: 'https://l.instagram.com/?u=http%3A%2F%2Fexplosm.net%2F&e=ATP6iwEee5ljZhUxLDvGA_BetWfzVVaL83v4EXbeeoBnZpwIk59J0KyWAgVWfYDHbmZpf3Fw', edge_followed_by: [Object], followed_by_viewer: false, edge_follow: [Object], follows_viewer: false, full_name: 'Cyanide & Happiness ????????', has_channel: false, has_blocked_viewer: false, highlight_reel_count: 21, has_requested_viewer: false, id: '10498164959', is_business_account: false, is_joined_recently: false, business_category_name: null, is_private: false, is_verified: false, edge_mutual_followed_by: [Object], profile_pic_url: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-19/s150x150/61484002_337325923611511_3151014486266085376_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com&_nc_ohc=emGC-lnlKXMAX8VvkqC&oh=3c8b2319e920822e1d5ae55f13001a37&oe=5ECB1ECC', profile_pic_url_hd: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-19/s320x320/61484002_337325923611511_3151014486266085376_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com&_nc_ohc=emGC-lnlKXMAX8VvkqC&oh=248dab515ef0e093fe81faf22c548542&oe=5ED14E3C', requested_by_viewer: false, username: 'cyanidehappinessvf2', connected_fb_page: null, edge_felix_video_timeline: [Object], edge_owner_to_timeline_media: [Object], edge_saved_media: [Object], edge_media_collections: [Object] } }, toast_content_on_load: null } ``` ### When it throws the error After removing my VPN, here is the result: ```js { captcha: { enabled: false, key: '' }, gdpr_required: true, tos_version: 'eu', username_hint: '' } ``` If you need further information, I'm available and I can make tests for you, if you cannot reproduce the bug.

Here is the list of the methods that work and those that don't:

Work Doesn't work
subcribeUserPosts x
getPost x
getHashtag x
getProfile x
searchProfile x
searchHashtag x
searchLocation x
subscribeHashtagPosts x
Here is the list of the methods that work and those that don't: | | Work | Doesn't work | |-----------------------|------|--------------| | subcribeUserPosts | | x | | getPost | x | | | getHashtag | x | | | getProfile | | x | | searchProfile | x | | | searchHashtag | x | | | searchLocation | x | | | subscribeHashtagPosts | x | |

I finally managed to reproduce your issue, after spamming Instagram with a hell of requests !

In fact, you're being redirected to Instagram's login page.

This behavior generally occurs when trying to authenticate using InstaClient.authBySessionId() with an invalid or expired session ID (i.e. HTTP 401).

In this case, however, it seems to be a reaction to spam (i.e. HTTP 429), unfortunately, I can't distinguish these two, so I made a fix that will do nothing more but detect the redirection and return a 401 error.

Anyway, using a VPN works as a bypass solution, while authenticating doesn't.

Thanks for reporting.

I finally managed to reproduce your issue, after spamming Instagram with a hell of requests ! In fact, you're being redirected to [Instagram's login page](https://www.instagram.com/accounts/login/). This behavior generally occurs when trying to authenticate using `InstaClient.authBySessionId()` with an invalid or expired session ID (i.e. HTTP 401). In this case, however, it seems to be a reaction to spam (i.e. HTTP 429), unfortunately, I can't distinguish these two, so I made [a fix](https://git.kaki87.net/KaKi87/ig-scraper/commit/56483b3c4d90ec62df17c84e24fa44f814692655) that will do nothing more but detect the redirection and return a 401 error. Anyway, using a VPN works as a bypass solution, while authenticating doesn't. Thanks for reporting.
KaKi87 added the
bug
label 2020-03-24 13:06:29 +01:00
Androz2091 started working 2021-03-04 16:48:24 +01:00
Androz2091 stopped working 2021-03-04 16:48:34 +01:00
10s
This repo is archived. You cannot comment on issues.
No Milestone
No Assignees
2 Participants
Total Time Spent: 10 seconds
Androz2091
10 seconds
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: KaKi87/scraper-instagram-v1#3
There is no content yet.