我正试图在Google上使用Selenium创建一个web刮刀脚本。然而,我收到了错误:
引发>/session/54df0082f43bf3d90fa9623057c3cf53/elements (_pool、url、error或ResponseError(原因)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(主机=‘127.0.0.1’,>port=53051):最大重试超过url: urllib3.exceptions.MaxRetryError(由>NewConnectionError引起(‘:未能建立新连接: Errno 61连接被拒绝’)
到目前为止,这是我关于使用selenium和webdriver的代码。
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
# Specifying incognito mode as you launch your browser[OPTIONAL]
option = webdriver.ChromeOptions()
option.add_argument("--incognito")
# Create new Instance of Chrome in incognito mode
browser = webdriver.Chrome(executable_path='/Users/emmanuelyamoah/Downloads/chromedriver-2', chrome_options=option)
# Go to desired website
browser.get("https://github.com/sonyemman")
# Wait 20 seconds for page to load
timeout = 20
try:
# Wait until the final element [Avatar link] is loaded.
# Assumption: If Avatar link is loaded, the whole page would be relatively loaded because it is among
# the last things to be loaded.
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((By.XPATH, "//img[@class='avatar width-full rounded-2']")))
except TimeoutException:
print("Timed out waiting for page to load")
browser.quit()发布于 2019-09-26 00:22:51
这不是您的代码错误,这是一个问题,您已经做了太多的网站,我强烈建议您使用这,因为它将确保每个对网站的请求来自不同的机器。
https://stackoverflow.com/questions/58107886
复制相似问题