gpt4 book ai didi

python - 套接字错误 : [Errno 54] Connection reset by peer Selenium-python

转载 作者:行者123 更新时间:2023-11-28 17:27:28 25 4
gpt4 key购买 nike

我是 selenium 的新手,正在尝试一个例子 http://www.marinamele.com/selenium-tutorial-web-scraping-with-selenium-and-python">这里

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException


def init_driver():
driver = webdriver.Firefox()
driver.wait = WebDriverWait(driver, 5)
return driver


def lookup(driver, query):
driver.get("http://www.google.com")
try:
box = driver.wait.until(EC.presence_of_element_located(
(By.NAME, "q")))
button = driver.wait.until(EC.element_to_be_clickable(
(By.NAME, "btnK")))
box.send_keys(query)
button.click()
except TimeoutException:
print("Box or Button not found in google.com")


if __name__ == "__main__":
driver = init_driver()
lookup(driver, "Selenium")
time.sleep(5)
driver.quit()

我已经使用

安装了 selenium
pip install selenium

但它不起作用。

出现的错误是

socket.error: [Errno 54] Connection reset by peer

有时

raise BadStatusLine(line)
httplib.BadStatusLine: ''

Firefox 打开然后关闭说“Firefox 意外退出”

我已经经历了Selenium headless browser webdriver [Errno 104] Connection reset by peerWhy am I getting this error in python ? (httplib)但没有任何帮助。

最佳答案

降级你的 firefox 并重试。看起来所有版本的 firefox 都不兼容 selenium。

引用:Selenium 2.50 not working on firefox 45

关于python - 套接字错误 : [Errno 54] Connection reset by peer Selenium-python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37685675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com