别累 好时光
我和我的几位同事从过去就一直在使用 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) 但这个问题还没有解决,也没有给出答案。
为了解决此问题,我尝试了以下方法:
我之前也遇到过 Instagram API 的问题,但后来我发现了 https://api.lamadava.com/docs 并为他们重写了我的项目
他们为一百个请求提供免费期,您可以使用我的促销代码https://lamadava.com/p/174ilqVv