2FA 在 Instaloader 中失败

2FA failing in Instaloader

正在尝试使用 Instaloader 登录 Instagram,

L = ig.Instaloader()
L.login(user, password)
L.two_factor_login(11111)

引发以下错误

raise TwoFactorAuthRequiredException("Login error: two-factor authentication required.")
instaloader.exceptions.TwoFactorAuthRequiredException: Login error: two-factor authentication required.

documentation 提到如果 2FA 登录的第一步完成,则会引发 TwoFactorAuthRequiredException,您应该调用 Instaloader.two_factor_login() - 但是因为引发了异常,所以在您的代码中,那个电话永远打不通。

试试这样的东西:

from instaloader.exceptions import TwoFactorAuthRequiredException

L = ig.Instaloader()

try:
    L.login(user, password)
except TwoFactorAuthRequiredException:
    L.two_factor_login(11111)