SolvedInstaPy TypeError: window.insta_data is undefined

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]
16 Answers

✔️Accepted Answer

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

Other Answers:

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

Related Issues:

44
InstaPy Login A/B test detected! Trying another string...
To anybody still having this issue on 6.1 Its caused by a typo in the file xpath_compile.py Line 159...
27
InstaPy ERROR Message: unknown error: DevToolsActivePort file doesn't exist
uncomment line chrome_options.add_argument('--no-sandbox') in your instapy.py should fix your proble...
25
InstaPy Not logging in anymore
You can just set the Switch language to False In instapy.py make self.switch_language = False ...
22
InstaPy Instagram Server Status: error
Solution 1: Add want_check_browser=False Solution 2: Edit the login_util.py file: Find and comment t...
21
InstaPy Selenium Unable to locate element
File: unfollow_util.py Solution: Before: Hi everyone ...
17
InstaPy like element has changed
Possible Changes in like_util.py @sionking could this work instead? any fix ? ...
16
InstaPy Raspberry Pi 3+ -> Error occured while deleting cookies
@JoeFertig thanks again! If it comes to that I will definitely check out some other microcomputers F...
10
InstaPy Install InstaPy on a Raspberry
finally made it!! i reversed the tutorial https://github.com/timgrossmann/InstaPy/blob/master/docs/H...
9
InstaPy Definetly not working on Raspberry Pi (3B+) - *Updated Instructions*
clean reinstall of raspbian on a rp3+ sudo apt-get update sudo apt-get upgrade pip3 install instapy ...
7
InstaPy cant get user followers
In unfollow_util.py Temporary replace with IT WORKS! Use this temporarily while wait for the officia...
7
InstaPy TypeError: window.insta_data is undefined
Today Bot start w/o any problem after some likes action the session end with this report: On the gec...
7
InstaPy Hide Selenium Extension: Error
Okay: I digged into it a little bit The problem seems to be with the arrive function within the fire...
6
InstaPy [FIX]IG Change Login Class Element - Cannot Creating Cookies or New Login Issue When Deleting Cookies
Please read New update : https://github.com/timgrossmann/InstaPy/issues/2133#issuecomment-394098747 ...
5
InstaPy Unfollow loop error: Message: unknown error: Cannot read property 'activity_counts' of undefined
Alright @tompicca Do this modification to get a total solution INFO [2018-08-19 11:27:42] [xxx] --> ...
5
InstaPy Follow likers function can't fetch likers properly
Hi @opexa I saw your problem while reading @timgrossmann's thread Getting likers from user: targetus...
3
InstaPy BUG or Instagram issue -- Super Strange behavior on Likes recently
@SDKFJ55LDK8K2 I'm just curious how did you get those numbers from ? For the majority of accounts th...
3
InstaPy Another XPath Error
@JodyHicks thanks for the hint that actually did the trick Hi everyone I have come across another XP...
425
puppeteer Failed to download Chromium r536395! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Solves the issue to me. Steps to reproduce Tell us about your environment: Puppeteer version: Not in...
365
puppeteer How to get text from a element ?
You can try this: or this: This might be a Obvious question but ...
326
puppeteer Chrome Headless doesn't launch on Debian
for the dockerisers amongst us - i've launched successfully with this setup: Running this example co...
289
vagrant vagrant box update - Fails with 404 Not Found error
A workarround to add in your Vagrantfile: Vagrant version Host operating system Ubuntu 16.04.3 LTS G...
285
puppeteer Ubuntu 18.04 Headless Chrome Node API - Puppeteer - Installation Guide
Based on https://github.com/GoogleChrome/puppeteer You only have to run the following command in Ubu...
263
vagrant vagrant --help displays a rubygems error
To fix this error: Vagrant version Host operating system Expected behavior vagrant and vagrant --hel...
252
puppeteer how to check if selector exists or is present ?
As a variant: how to check if selector exists or is present waiting for (x) time or when the page is...
233
puppeteer Installation fails on Apple Silicon / M1
The solution for me using Chromium from Homebrew was: You will get a security warning ...
200
puppeteer npm install -g puppeteer fails
This command ended up working for me in case anyone lands here by googling the error: sudo npm insta...
169
phantomjs QXcbConnection: Could not connect to display
can confirm export QT_QPA_PLATFORM=offscreen before selenium scripts work's well. ...
162
puppeteer can't run puppeteer in centos7
@zhuyingda 's notes above will allow you to run puppeteer with --no-sandbox Server Info: CUP: Intel(...
155
puppeteer Headless mode is not working
I had the same issue I then added await page.screenshot(...) to see what's going on in headless mode...
134
vagrant Vagrant up forces shutdown of VM
Update: Please upgrade vagrant to 1.9.5 as it's released The version contains fix for this issue ...
116
puppeteer Run from Electron
For me the solution was a combination of the approach of @qathom and @tpkn: But in my case the array...
104
fastlane Connection reset by peer
Thanks for the fix! got me back in business New Issue Checklist Updated fastlane to the latest versi...
102
puppeteer How to scrape an element
The following should work: Hi I think this is an obvious question but still I cannot figure out how ...
98
puppeteer ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported
@ststeiger so which are the launch options? Like Or do I need to add args: ['--no-sandbox' '--disabl...
96
puppeteer Page.setContent should wait for resources to be loaded
Meanwhile a good workaround for page.setContent that waits for all the resources to load: ...
91
vagrant 1.8.7 fails to download or update boxes
I just sudo rm -rf /opt/vagrant/embedded/bin/curl and it works now It's looked like vagrant can fall...
81
puppeteer Request: browser.currentPage() or similar way to access Pages
To get the first page of the current browser I was playing around with Puppeteer today and I found o...
75
puppeteer Error: Failed to launch chrome! spawn /app/node_modules/puppeteer/.local-chromium/linux-609904/chrome-linux/chrome ENOENT
@arapocket Thanks for commenting—I forgot to follow up after I found a solution It's been a couple o...
69
vagrant VBoxManage.exe: error: Invalid NIC number
Confirm the problem It is reproduced with Windows10/Vagrant 1.8.3/VirtualBox 5.0.20 and hashicorp/pr...
68
puppeteer Error: Failed to launch the browser process! spawn chrome.exe ENOENT
For me on Linux the only way to resolve is by installing some dependencies: Source ...
68
puppeteer EventEmitter memory leak detected. 11 exit listeners added
@selfrefactor ah indeed you launch chrome processes in parallel Every chrome instance adds a listene...
67
vagrant Openssl error on Vagrant 1.8.7 / MacOs Sierra
The workaround to link the existing openssl as proposed in GH-7747 seems to work as well sudo ln -sf...
66
puppeteer Collect element attributes from selector
i think this would do it And once #625 is implemented this will be.. Beginner user here Started play...
65
fastlane firebase_app_distribution plugin doesn't work in macOS Catalina
Looks like files in firebase_app_distribution plugin have incorrect permissions 640 by default ...
64
puppeteer Puppeteer Won't Click on Element
In my case I'm able to use this reliably: page.$eval(selectorStr elem => elem.click()); ...
60
puppeteer Execution context was destroyed, most likely because of a navigation
@THE-GAME-YOU-LOST I see The right thing to do would be to await navigation caused by page.click ...
60
puppeteer Page.click() does not work with an input selector
I'm running into the same issue Strangely if I use page.evaluate it does work For example: I'd be cu...
59
puppeteer Different behavior between { headless: false } and { headless: true }
As mentioned in the article @Garbee posted the headless version does not have languages set on the n...
57
fastlane fastlane gym produces error: method `to_plist' not defined in Array
Alright New Issue Checklist Updated fastlane to the latest version I read the Contribution Guideline...