我用 selenium 在 python 中编写了一个脚本来从网页中获取标题地址。我在脚本中使用的 url 会在几秒钟内自动重定向。这是我的脚本遇到错误的地方。我正在粘贴该错误的一部分以给您一个想法。
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
我试过的脚本:
from contextlib import closing
from selenium import webdriver
from selenium.webdriver.support import ui
url = "https://www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=30578943&contentId=1625965454&index=1"
with closing(webdriver.Chrome()) as wd:
wait = ui.WebDriverWait(wd, 10)
wd.get(url)
item = wait.until(lambda driver: driver.find_element_by_css_selector("h1.header_address__title")).text
print(item)
这是我希望从该页面获得的输出:
Park View Back Road, Locharbriggs, Dumfries, DG1
这是我在该错误之前看到的:
天涯尽头无女友
相关分类