Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Query to <username>/feed/: Could not find "window._sharedData" in html response. #1553

Closed
legalizetren opened this issue May 31, 2022 · 53 comments · Fixed by #1561
Closed
Labels
bug Bug

Comments

@legalizetren
Copy link

legalizetren commented May 31, 2022

Describe the bug
JSON Query to test/feed/: Could not find "window._sharedData" in html response. [retrying; skip with ^C]

To Reproduce
Steps to reproduce the behavior: just download anyone

Expected behavior
its supposed to work

Error messages and tracebacks
If applicable, add error messages and tracebacks to help explain your problem.
Errors or warnings occurred:
Profile test has changed its name to test.
Warning: test will be downloaded anonymously ("Profile test does not exist.
The most similar profile is: test.")

@legalizetren legalizetren added the bug Bug label May 31, 2022
@RuzgarErik
Copy link

There might a update for the instagram api and the web interface, the instagam downloader extension stopped working

@getYourFlag
Copy link

Just got the same issue.

First there are multiple exceptions with this error message:
instaloader.exceptions.QueryReturnedNotFoundException: Could not find "window._sharedData" in html response.

Then there is one exception as below:
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to <username>/feed/: Could not find "window._sharedData" in html response.

At last, instaloader complains that the profile could not be found, with the below error message:
instaloader.exceptions.ProfileNotExistsException: Profile <username> does not exist.
The most similar profile is: <username>.
Both usernames are the same.

The profile that I attempted to download is clearly visible in Instagram, they probably made some changes in the HTML response.

@quietsecret123
Copy link

quietsecret123 commented May 31, 2022

Hello, I'm a user of Raider (a different IG scraping program). I thought I'd hop in here to chime in since the Raider github is kind of dead. It seems they're blocking certain usernames only... I tried various usernames of mine, and some of them work, and some do not.

(To clarify, the usernames of the accounts I want to download are all working. The usernames I login as are the wonky ones... sometimes they work, sometimes they don't)

@RuzgarErik
Copy link

I tried an another account of mine and it downloaded, without a problem. It's probably a measure to preventing bot accounts

@quietsecret123
Copy link

quietsecret123 commented May 31, 2022

They blocked 2 of my accounts a few weeks ago then I retried them today. They seem to be working again, so it appears to be a temporary measure (for now). However, they blocked more of my accounts today, though

@AnonC0DER
Copy link

Same problem here, I got "Could not find "window._sharedData" in html response." error.
I tried 10 accounts, none of them worked. It seems something has changed in Instagram sessions.
Has anybody found any solution?

@ekalin
Copy link
Collaborator

ekalin commented May 31, 2022

The workaround is to remove the session file (session-USERNAME in the config directory, or whichever file you specify in the command-line) and force a login every time instaloder runs. Not great, but it seems to work.

@Showmaster3000
Copy link
Collaborator

The problem is also discussed in #1530.

@MrC0D3
Copy link

MrC0D3 commented Jun 1, 2022

Also discussed in #1523

@ghost
Copy link

ghost commented Jun 1, 2022

This is what you get as a response for "good" (i.e. log in with fresh session and grab stories immediately) vs "bad" (i.e. use existing session, even for a few seconds before):
stories.zip

@elbreujeu
Copy link

The workaround is to remove the session file (session-USERNAME in the config directory, or whichever file you specify in the command-line) and force a login every time instaloder runs. Not great, but it seems to work.

Works but got banned within 2 times of using this workaround, be careful guys😢

@quietsecret123
Copy link

In the DataHoarder subreddit, someone also said the Chrome extension has stopped working, so something is going on with IG...

@quietsecret123
Copy link

I decided to download 4KStogram again, which forced me to login to an account to download stories. I logged in as one of my blocked accounts, and the app was surprisingly able to download the stories, so there is definitely a workaround.

@ziemek99
Copy link
Contributor

ziemek99 commented Jun 2, 2022

The workaround is to remove the session file (session-USERNAME in the config directory, or whichever file you specify in the command-line) and force a login every time instaloder runs. Not great, but it seems to work.

Works but got banned within 2 times of using this workaround, be careful guys😢

What do you mean exactly by "banned"? Banned just from scraping (you can still log in), banned temporarily (you can't react to content) or banned completely (removed)?

@thariq-nugrohotomo
Copy link

Is it possible to edit this issue title, as currently it's not mentioning what the actual issues are?
Other closed issue's title is more representative, e.g. error Could not find "window._sharedData" in html response

@elbreujeu
Copy link

The workaround is to remove the session file (session-USERNAME in the config directory, or whichever file you specify in the command-line) and force a login every time instaloder runs. Not great, but it seems to work.

Works but got banned within 2 times of using this workaround, be careful guys😢

What do you mean exactly by "banned"? Banned just from scraping (you can still log in), banned temporarily (you can't react to content) or banned completely (removed)?

Just got a softban, I had to reinitialize my password by SMS and got access to my account again

@fireattack
Copy link
Collaborator

fireattack commented Jun 2, 2022

Excessive logins always get your account ban or locked so it's not specific to that workaround. But yeah, be aware.

@nns33213
Copy link

nns33213 commented Jun 2, 2022

@ekalin @fireattack @jbrre this is not a real workaround, just a coincidence due to the way Instagram releases patches.

I'd advise not to burn your accounts and just wait for a real fix. This "workaround" will stop working completely within the next hours or days.

@Showmaster3000
Copy link
Collaborator

This is what you get as a response for "good" (i.e. log in with fresh session and grab stories immediately) vs "bad" (i.e. use existing session, even for a few seconds before): stories.zip

Just checked your files. The "bad" version doesn't have the window._sharedData in the code. Instead parts of the content is at another position near XIGSharedData but without the graphql-part...

@elbreujeu
Copy link

@ekalin @fireattack @jbrre this is not a real workaround, just a coincidence due to the way Instagram releases patches.

I'd advise not to burn your accounts and just wait for a real fix. This "workaround" will stop working completely within the next hours or days.

How "bad" is it? Like is it just an API update or is the good old login method completely broken?

@nns33213
Copy link

nns33213 commented Jun 2, 2022

How "bad" is it? Like is it just an API update or is the good old login method completely broken?

@jbrre no, I don't think login is broken. From what I've seen working on patch for other project, yes, window._sharedData is gone. Most of the data can be found around PolarisProfileRoot.react from the "bad" response (not XIGSharedData which holds data for your own account) and also the endpoint for getting media info no longer works (not sure if InstaLoader uses it though).

@francescogrimaldi
Copy link

francescogrimaldi commented Jun 2, 2022

I have noticed a new API endpoint i.instagram.com/api/v1/users/web_profile_info/?username={profile_name}

@afterdelight
Copy link

please change the title to be more specific, thanks

@AyluinReymaer
Copy link

I also started having the same issue:

instaloader.exceptions.QueryReturnedNotFoundException: Could not find "window._sharedData" in html response.
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to test/feed/: Could not find "window._sharedData" in html response.,
instaloader.exceptions.ProfileNotExistsException: Profile test does not exist.

@tayfunyasar
Copy link

entry_data is also empty if you check _sharedData. So are we going to give up? 😆

@afterdelight
Copy link

ty, its working now. the pull request should have been updated with your fix.

@twitter-79
Copy link
Contributor

this is weird, for me trying a non-existing profile leads to various tries ending in a 404 and finally a keyerror on fetching similar profiles as the data only contains a username but no id.

Do you have a username that leads to an empty user field for me to try things out?

@Dibort
Copy link

Dibort commented Jun 4, 2022

Do you have a username that leads to an empty user field for me to try things out?

noxandwillow was a 404 but oskar_blackbeard not. Maybe something about users changing their profile names? I don't know.

@UnixCro
Copy link

UnixCro commented Jun 4, 2022

If I delete the sessionfile then download the download easily. So it works instaloader itself, only as soon as the session file is retrieved, there is a problem that we have to look at. What makes instaloader different?

@fireattack
Copy link
Collaborator

makes instaloader different

It's not different. It happens with webpage too.

It looks like that Instagram just doesn't seem to send back the same response when you firstly login.

@twitter-79
Copy link
Contributor

Do you have a username that leads to an empty user field for me to try things out?

noxandwillow was a 404 but oskar_blackbeard not. Maybe something about users changing their profile names? I don't know.

this really is weird... I added your fix to the pull request. Thx for helping out!
I guess we can use the PR as a quick fix until someone else has time to do it correctly

@MiguelX413
Copy link
Contributor

It suddenly started working again for me.

@baris12333
Copy link

@quietsecret123 Is the issue the same on Raider? I have been trying to rig Raider to work similarly to how Instaloader has been fixed in this thread but haven't had luck with the older packages it uses. Npm doesn't want to install them. Does Instaloader have a way it can read everything Ive downloaded from Raider so I don't have to re-download all the accounts from scratch to switch over to Instaloader?

@wolviey
Copy link

wolviey commented Jun 5, 2022

patch worked for me thx.

@UnixCro
Copy link

UnixCro commented Jun 5, 2022

How I can install the patch via pip?

@elbreujeu
Copy link

How I can install the patch via pip?

Uninstall your old instaloder version.
Clone the patch repository.
Then go into the patch repo and pip3 install -e .

@AnonC0DER
Copy link

What does patch repository mean?
How can clone it?

@jlntrt
Copy link

jlntrt commented Jun 5, 2022

Just use pip3 install --upgrade --user git+https://github.com/twitter-79/instaloader

@afterdelight
Copy link

open cmd then write 'pip install https://github.com/twitter-79/instaloader/archive/refs/heads/master.zip --no-cache-dir'

@UnixCro
Copy link

UnixCro commented Jun 5, 2022

I think, it is the best to run this.

pip install --force-reinstall -U git+https://github.com/instaloader/instaloader@refs/pull/1561/merge

@jiatern
Copy link

jiatern commented Jun 5, 2022

Just use pip3 install --upgrade --user git+https://github.com/twitter-79/instaloader

Tried this on my Ubuntu machine and it worked perfectly. UnixCro's method gave me an error.

@UnixCro
Copy link

UnixCro commented Jun 5, 2022

@jiatern UnixCro's method gave me an error.

The Error is probably this pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. ... It still works without any problems.

@aandergr aandergr changed the title brokey JSON Query to <username>/feed/: Could not find "window._sharedData" in html response. Jun 16, 2022
@brutalsuperman

This comment was marked as abuse.

@axelmiami
Copy link

axelmiami commented Sep 10, 2022

Exactly the same problem:

$ instaloader --login=<username>
Session file does not exist yet - Logging in.
Enter Instagram password for p2i.berest:
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]
Fatal error: JSON Query to accounts/login/: Could not find "window._sharedData" in html response.

help me please

Moreover, when launched locally from the IDE, everything connects and works, but on the server it gives an error.

All Python packages are the same and updated to the latest versions.

$ python3 -m pip install instaloader -U
Requirement already satisfied: instaloader in ./venv/lib/python3.8/site-packages (4.9.3)
Requirement already satisfied: requests>=2.4 in ./venv/lib/python3.8/site-packages (from instaloader) (2.28.1)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.8/site-packages (from requests>=2.4->instaloader) (2022.6.15.1)
Requirement already satisfied: charset-normalizer<3,>=2 in ./venv/lib/python3.8/site-packages (from requests>=2.4->instaloader) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.8/site-packages (from requests>=2.4->instaloader) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./venv/lib/python3.8/site-packages (from requests>=2.4->instaloader) (1.26.12)`

All of the above methods did not help.
Both the call from Python and the call in the console do not work on the server

@afterdelight
Copy link

try uninstall then fresh install of instaloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.