Instapy: TypeError: window.insta_data is undefined

Created on 9 Sep 2019  路  15Comments  路  Source: timgrossmann/InstaPy

Bot start w/o any problem, after some likes action the session end with this report:

Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 592, in check_link
    "window.insta_data = window.__additionalData[Object.keys(window.__additionalData)[0]].data"
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.__additionalData[Object.keys(...)[0]] is undefined


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "InstaPy/assets/tbmusic.py", line 42, in <module>
    'memoriesmusic_', 'rgambasin', 'iambenhamilton', 'ale.x.official', 'gh__ph', 'asbronzatissimi'], amount=10, randomize=True)
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 3185, in interact_user_followers
    self.user_interact_media,
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 2517, in interact_by_users
    self.logger,
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 596, in check_link
    "window.insta_data = window._sharedData.entry_data.PostPage[0]"
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/root/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window._sharedData is undefined

On the geckodriver.log appear this error after the error above:

JavaScript error: resource://devtools/client/jsonview/converter-observer.js, line 89: NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIChannel.contentType]
wontfix

Most helpful comment

Today, with the "dev" branch and 0.6.4 version of instapy i've to report again the issue after 6 some likes:

Traceback (most recent call last):
  File "/home/pi/InstaPy/assets/scriptname.py", line 73, in <module>
    skip_top_posts=True)
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 1482, in like_by_locations
    self.logger,
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 613, in check_link
    user_name,
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.insta_data is undefined

geckodriver 0.23
RaspBerry Pi3+
Mozilla Firefox 60.9.0

Another one (UPDATE):

Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 592, in check_link
    "window.insta_data = window.__additionalData[Object.keys(window.__additionalData)[0]].data"
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.__additionalData[Object.keys(...)[0]] is undefined


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/InstaPy/assets/scriptname.py", line 73, in <module>
    skip_top_posts=True)
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 1482, in like_by_locations
    self.logger,
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 596, in check_link
    "window.insta_data = window._sharedData.entry_data.PostPage[0]"
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window._sharedData is undefined

All 15 comments

Same here

in "like_util.py"
def check_link(

at line 557 change from

    try:
        post_page = browser.execute_script(
            "return window.__additionalData[Object.keys(window.__additionalData)[0]].data"
        )

    except WebDriverException:  # handle the possible `entry_data` error
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            post_page = browser.execute_script(
                "return window._sharedData.entry_data.PostPage[0]"
            )

        except WebDriverException:
            post_page = None

to

try:
    post_page = browser.execute_script(
        "return window._sharedData.entry_data.PostPage[0]"
    )
except WebDriverException:  # handle the possible `entry_data` error
    post_page = None

Now I get this:

Message: The element reference of <button class=" ffKix _0mzm- sqdOP  L3NKy _4pI4F"
type="button"> is stale; either the element is no longer attached to the DOM, it is not in
the current frame context, or the document has been refreshed

I've done the change
Appeared this message (there are more bot doing operations in the same time, one is going well):

WARNING [2019-09-10 10:00:52] [freemake.official]  Unable to save account progress, skipping data update Message: TypeError: window._sharedData is undefined

But the script is going ahead in any case.

I've done the change
Appeared this message (there are more bot doing operations in the same time, one is going well):
WARNING [2019-09-10 10:00:52] [freemake.official] Unable to save account progress, skipping >data update Message: TypeError: window._sharedData is undefined

in print_log_writer.py file:

line 25

    try:
        followed_by = browser.execute_script(
            "return window.__additionalData[Object.keys(window.__additionalData)[0]].data."
            "graphql.user.edge_followed_by.count"
        )

    except WebDriverException:  # handle the possible `entry_data` error
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            sleep(1)
            followed_by = browser.execute_script(
                "return window._sharedData."
                "entry_data.ProfilePage[0]."
                "graphql.user.edge_followed_by.count"
            )

        except WebDriverException:
            followed_by = None

change to:

    try:
        followed_by = browser.execute_script(
            "return window._sharedData."
            "entry_data.ProfilePage[0]."
            "graphql.user.edge_followed_by.count"
        )

    except WebDriverException:  # handle the possible `entry_data` error
        followed_by = None

also line 58:

    try:
        following_num = browser.execute_script(
            "return window.__additionalData[Object.keys(window.__additionalData)[0]].data."
            "graphql.user.edge_follow.count"
        )

    except WebDriverException:
        try:
            browser.execute_script("location.reload()")
            update_activity(browser, state=None)

            sleep(10)
            following_num = browser.execute_script(
                "return window._sharedData."
                "entry_data.ProfilePage[0]."
                "graphql.user.edge_follow.count"
            )

        except WebDriverException:
            following_num = None

change to:

    try:
        following_num = browser.execute_script(
            "return window._sharedData."
            "entry_data.ProfilePage[0]."
            "graphql.user.edge_follow.count"
        )

    except WebDriverException:
        following_num = None

I've done the changes, now I will test the same script. Thanks

UPDATE:
It works!
Thanks again!

I put pull request for the fix
https://github.com/timgrossmann/InstaPy/pull/5046

INFO [2019-09-12 23:31:38] [xxx]  Saving account progress...
INFO [2019-09-12 23:32:32] [xxx]  Failed to get followers count of 'b'earthportfolio''  ~empty list
INFO [2019-09-12 23:33:23] [xxx]  Failed to get following count of 'b'earthportfolio''  ~empty list
WARNING [2019-09-12 23:33:23] [xxx]  Unable to save account progress, skipping data update Message: TypeError: window._sharedData.entry_data.ProfilePage is undefined

Today i noticed this :( any others do?

Today, with the "dev" branch and 0.6.4 version of instapy i've to report again the issue after 6 some likes:

Traceback (most recent call last):
  File "/home/pi/InstaPy/assets/scriptname.py", line 73, in <module>
    skip_top_posts=True)
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 1482, in like_by_locations
    self.logger,
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 613, in check_link
    user_name,
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.insta_data is undefined

geckodriver 0.23
RaspBerry Pi3+
Mozilla Firefox 60.9.0

Another one (UPDATE):

Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 592, in check_link
    "window.insta_data = window.__additionalData[Object.keys(window.__additionalData)[0]].data"
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.__additionalData[Object.keys(...)[0]] is undefined


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/InstaPy/assets/scriptname.py", line 73, in <module>
    skip_top_posts=True)
  File "/root/.local/lib/python3.7/site-packages/instapy/instapy.py", line 1482, in like_by_locations
    self.logger,
  File "/root/.local/lib/python3.7/site-packages/instapy/like_util.py", line 596, in check_link
    "window.insta_data = window._sharedData.entry_data.PostPage[0]"
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window._sharedData is undefined

Same here. Same setup as above.

Same here

Same for me too

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue

If you're still running into an issue.
Its appearing to be more of a rate limit with calls to Instagram's Server.

Before running the script again, try the following.

  • Delete the cookie file saved by Instapy
  • Renew your IP address within your cmd

ipconfig /release
ipconfig /renew

Hope this helps :)

Has anyone managed to overcome this issue?
I tried multiple different servers (hence different IPs) and I get the same error on each one.

Any tips on how to fix it?

Was this page helpful?
0 / 5 - 0 ratings