![](/img/trans.png)
[英]Python socket ConnectionResetError: [Errno 54] Connection reset by peer vs socket.error: [Errno 104] Connection reset by peer
[英]socket.error: [Errno 54] Connection reset by peer Selenium-python
我是selenium的新手,並嘗試了一個示例http://www.marinamele.com/selenium-tutorial-web-scraping-with-selenium-and-python"> where
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無頭瀏覽器webdriver [Errno 104]連接重置由同行和為什么我在python中收到此錯誤? (httplib)但沒有任何幫助。
降級你的firefox並再試一次。看起來像所有版本的firefox都與selenium不兼容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.