对帐户/登录/进行 JSON 查询:在 html 响应中找不到“window._sharedData”。 [重试;使用 ^C] 跳过

问题描述 投票:0回答:1

别累 好时光

我和我的几位同事从过去就一直在使用 instaloader,并且仍在工作。但最后一次(新更新后),我们在 Instagram 的登录帐户中遇到了严重的问题,我们发现不仅是我们,很多人都面临这个问题。

代码片段:

import instaloader

# Get instance
L = instaloader.Instaloader()

# Optionally, login or load session
L.login(USER, PASSWORD)        # (login)

错误:

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 "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 410, 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 "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 410, 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 "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 410, 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 "main.py", line 5, in <module>
    L.login(..., ....)
  File "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloader.py", line 651, in login
    self.context.login(user, passwd)
  File "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 259, in login
    csrf_json = self.get_json('accounts/login/', {}, session=session)
  File "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 448, in get_json
    return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
  File "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 448, in get_json
    return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
  File "/home/runner/code/venv/lib/python3.10/site-packages/instaloader/instaloadercontext.py", line 436, 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.

显然这个问题也是在2022年9月11日提出的。(问题代码1737) 但这个问题还没有解决,也没有给出答案。

为了解决此问题,我尝试了以下方法:

  1. 仔细检查您的 Instagram 用户名和密码是否正确
  2. 我用几个 Instagram 帐户和几个不同的用户名和密码检查了代码和此错误。
  3. 暂时禁用您帐户的双因素身份验证,看看是否可以解决问题。
  4. 使用 pip 将 instaloader 库更新到最新版本:pip3 install --upgrade instaloader。
instagram-api
1个回答
0
投票

我之前也遇到过 Instagram API 的问题,但后来我发现了 https://api.lamadava.com/docs 并为他们重写了我的项目

他们为一百个请求提供免费期,您可以使用我的促销代码https://lamadava.com/p/174ilqVv

© www.soinside.com 2019 - 2024. All rights reserved.