instaloader: JSON Query to accounts/login/: Could not find "window._sharedData" in html response. [retrying; skip with ^C]
The code I use for this is:
import instaloader
loader = instaloader.Instaloader()
loader.login(user="", passwd="")
print("✅ 1- Logged in")
The output is:
JSON Query to accounts/login/: Could not find "window._sharedData" in html response. [retrying; skip with ^C]
JSON Query to accounts/login/: Could not find "window._sharedData" in html response. [retrying; skip with ^C]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 357, in get_json
raise QueryReturnedNotFoundException("Could not find \"window._sharedData\" in html response.")
instaloader.exceptions.QueryReturnedNotFoundException: Could not find "window._sharedData" in html response.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 357, in get_json
raise QueryReturnedNotFoundException("Could not find \"window._sharedData\" in html response.")
instaloader.exceptions.QueryReturnedNotFoundException: Could not find "window._sharedData" in html response.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 357, in get_json
raise QueryReturnedNotFoundException("Could not find \"window._sharedData\" in html response.")
instaloader.exceptions.QueryReturnedNotFoundException: Could not find "window._sharedData" in html response.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/teungrondman/Documents/projects/python/getfollowers_insta/test.py", line 5, in <module>
loader.login(user="the_followweb", passwd="Aapje40")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloader.py", line 634, in login
self.context.login(user, passwd)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 214, in login
csrf_json = self.get_json('accounts/login/', {}, session=session)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 395, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 395, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 383, in get_json
raise QueryReturnedNotFoundException(error_string) from err
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to accounts/login/: Could not find "window._sharedData" in html response.
To troubleshoot this issue I tried the following:
- Double-check your Instagram username and password for correctness
- Disable two-factor authentication for your account temporarily and see if that resolves the issue.
- Update the instaloader library to the latest version using pip:
pip3 install --upgrade instaloader.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 23
- Comments: 35
i am facing same issue , so i go to troubleshooting section from following link https://instaloader.github.io/troubleshooting.html search for “Login error” on page so solution is there
First download “[https://raw.githubusercontent.com/instaloader/instaloader/master/docs/codesnippets/615_import_firefox_session.py]” this file To use this script,
Download the script: Example 615_import_firefox_session.py,
Login to Instagram in Firefox,
Execute the snippet, e.g. with python 615_import_firefox_session.py,
Then, instaloader -l USERNAME should work fine.
And you can manually transfer cookies, you need only
sessionidandcsrftoken. Something like this:Of course you need to get real values instead of my placeholders. You can use any tools that your browser provide.
Facing the same error running in Docker. I have cloned the latest 4.10 from Git, and generated new session file. Receiving this error.
Almost one month and no solution (we can’t use “get_stories()” with load_session solution), anyone have an alternative ?
Thanks! This fixed the problem, although I skipped the last step.
Hello Do not be tired Good time
I and several of my colleagues have been working with instaloader since the past and are still working. But for the last time (after the new update), we came across a serious problem in the login account of Instagram and we found out that not only us, but many people are facing this problem.
Code Snippet:
error:
To troubleshoot this issue I tried the following:
Apparently, this problem was also raised on Sep 11, 2022. (issues code 1737) But this problem has not been solved and no answer has been given.
JSON Query to accounts/login/: Could not find “window._sharedData” in html response. [retrying; skip with ^C] JSON Query to accounts/login/: Could not find “window._sharedData” in html response. [retrying; skip with ^C] Traceback (most recent call last):
I’m encountering the error. I couldn’t handle it.
As @killergod143 mentioned
follow the same steps and last step is not needed. ( Then, instaloader -l USERNAME should work fine )
It works!! Thanks 😃
Thanks for the fast reply. I actually just downloaded wfdownloader, and was able to download 3x profiles in a few minutes. I couldn’t be bothered with the constant errors.
I had the same issue, and attempting to import my Firefox cookies as instructed on the troubleshooting page wasn’t working. I figured out that it’s because I use Firefox as my default browser, while most people are using it just to access the cookie file, so I had to change the ‘*’ in the cookie path in the code to the name of the folder for my Firefox profile (should end in ‘default-release’ instead of ‘default’).
You can follow the steps from my answer 🙂
In python, I followed this way and it’s solved. Thanks to @killergod143 and @aleaksah for their answers
Steps:
Same… still waiting for a update!
The only solution worked for me is @aleaksah’s comment above. I manually bring cookie data from chrome and it worked. Firefox method didn’t work for me.
I followed the instruction below basically and it worked!
Here are some additional info to share:
I do no know what “last step” in ronakjain2012’s comment mean, but both “Login to Instagram in Firefox” and “Execute the snippet, e.g. with python 615_import_firefox_session.py” seem to be needed.