简体   繁体   English

尝试登录 instaloader python 时出错

[英]Error when trying to log in to instaloader python

When I try to login to instaloader through Terminal, I get this error:当我尝试通过终端登录到 instaloader 时,我收到此错误:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/instaloader", line 33, in <module>
    sys.exit(load_entry_point('instaloader==2.2.1', 'console_scripts', 'instaloader')())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader.py", line 1160, in main
    loader.download_profiles(args.profile, args.login.lower() if args.login is not None else None, args.password,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader.py", line 983, in download_profiles
    self.interactive_login(username)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader.py", line 959, in interactive_login
    self.login(username, password)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/instaloader.py", line 516, in login
    session.headers.update({'X-CSRFToken': login.cookies['csrftoken']})
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='csrftoken', domain=None, path=None"

I have not edited or changed anything in the scripts it is showing, so I do not know what is wrong.我没有编辑或更改它显示的脚本中的任何内容,所以我不知道出了什么问题。

If you would like to login through python script them this snippet of code will get you there如果你想通过 python 脚本登录,这段代码会让你到达那里

from instaloader import Instaloader
USERNAME = "YOUR USERNAME"
PASSWORD = "YOUR PASSWORD"

L = Instaloader()
L.login(USERNAME, PASSWORD)
from instaloader import Instaloader, Profile
L = Instaloader()
username = "ur username"
password = "ur password"
L.login(username, password)
profile = Profile.from_username(L.context, username)
posts_sorted_by_likes = sorted(profile.get_posts(), key=lambda post: post.likes,reverse=True)
for post in posts_sorted_by_likes:
if post.is_video:
L.download_post(post, username)

properly arrange the code it will run successfully正确安排它将成功运行的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM