【问题标题】:Cannot load the website I want to on remote PC through selenium compressed as exe file无法通过压缩为 exe 文件的 selenium 在远程 PC 上加载我想要的网站
【发布时间】:2022-01-14 13:08:46
【问题描述】:

我写了一些 python 脚本结合 selenium 来自动登录一个网站,它在我的电脑上运行良好。 现在我将脚本压缩为exe文件以在远程PC上运行,但它无法加载页面,卡在“访问xxx之前检查您的浏览器”。 为什么?

这是我的代码:

op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches',['enable-logging'])
ser = Service('chromedriver.exe')
wd = webdriver.Chrome(service=ser,options=op)
wd.get(self.url)
# time.sleep(30)
try:

    email_input = WebDriverWait(wd,30).until(
        EC.presence_of_element_located((By.ID,"user_email"))
    )
except Exception as e:
    print(e)

【问题讨论】:

    标签: python selenium


    【解决方案1】:

    snapshot 中可以明显看出cloudflaredetected your program 作为 并且阻止了进一步的导航。

    为了防止被检测到,您可以通过add_argument()添加以下参数:

    --disable-blink-features=AutomationControlled

    示例代码块:

    op = webdriver.ChromeOptions()
    op.add_experimental_option("excludeSwitches", ["enable-automation"])
    op.add_experimental_option('excludeSwitches', ['enable-logging'])
    op.add_experimental_option('useAutomationExtension', False)
    op.add_argument('--disable-blink-features=AutomationControlled')
    ser = Service('C:\\BrowserDrivers\\chromedriver.exe')
    wd = webdriver.Chrome(service=ser,options=op)
    wd.get(self.url)
    

    【讨论】:

    • 对不起,兄弟,这种方法对我不起作用。
    猜你喜欢
    • 1970-01-01
    • 2018-10-06
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    • 1970-01-01
    • 2014-09-01
    • 2020-02-09
    • 2012-03-18
    相关资源
    最近更新 更多