Python Can’;t使用InstaPy登录

Python Can’;t使用InstaPy登录,python,authentication,instapy,Python,Authentication,Instapy,我试图在Instagram页面上使用一些机器人,但我无法登录 这是我的代码: from instapy import InstaPy session = InstaPy(username='' ,password='') session.login() 我得到了这个错误: SessionNotCreatedException: Expected browser binary location, but unable to find binary in default location, no

我试图在Instagram页面上使用一些机器人,但我无法登录

这是我的代码:

from instapy import InstaPy
session = InstaPy(username='' ,password='') 
session.login()
我得到了这个错误:

SessionNotCreatedException: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
我有最新版本的Firefox


谢谢大家!

您的代码应该如下所示:

from instapy import InstaPy

session = InstaPy(username='', password='')
session.login()
请确保将您使用的Instagram帐户的登录信息也放入用户名和密码参数中。

My Solution 在会话实例中通过浏览器\u可执行文件\u路径=r“C:[自定义位置]”

重新安装Firefox对我不起作用

解释 该消息意味着GeckoDriver在尝试启动/生成新的浏览上下文(即Firefox浏览器会话)时无法定位Firefox二进制文件(Firefox.exe)

为什么? 可能有以下两个原因之一:

  • 您的系统中未安装Firefox
  • Firefox未安装在系统中的默认位置
  • 通常,任何硒项目都需要

        options = webdriver.firefox.options.Options()
        options.binary_location = r"C:\Program Files\Mozilla Firefox\firefox.exe"
        browser = webdriver.Firefox(options=options)
    
    …对于通过Options()实例传递firefox二进制文件绝对路径的自定义位置,但由于InstaPy负责初始化浏览器,因此必须通过类属性“browser\u executable\u path”传递该路径

    TL;DR:添加InstaPy类的参数browser\u executable\u path允许我将r“C:[自定义Firefox位置]”作为Firefox位置传递

    参考资料


    阅读记账代码段的stackoverflow指南。从instapy导入instapy session=instapy(用户名='',密码='')session.login()应该是这样的
    谢谢您的回复,我仍然收到相同的错误。SessionNotCreatedException:预期的浏览器二进制位置,但在默认位置找不到二进制,未提供“moz:firefoxOptions.binary”功能,并且在命令行上未设置二进制标志。这都是修复将FIREFOX放在编辑变量路径上的问题
    
        selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
    
        options = webdriver.firefox.options.Options()
        options.binary_location = r"C:\Program Files\Mozilla Firefox\firefox.exe"
        browser = webdriver.Firefox(options=options)