【发布时间】:2021-08-25 11:15:22
【问题描述】:
所以我被困在这里无法前进大约 2 周。我正在尝试找到一个元素并对其进行截图,但我不断收到此内容
No connection could be made because the target machine actively refused it
这是我想要获取的元素:
<img id="action_captcha" src="URL HERE" alt="CAPTCHA code" style="vertical-align:middle;">
这是我的代码:
try:
print("1")
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "action_captcha"))
)
print("2")
image = element.screenshot("Captcha.png")
print("3")
except Exception as e:
print(e)
我得到的只是
1
No connection could be made because the target machine actively refused it
我知道没有防火墙阻止连接,因为在此之前我在同一个浏览器实例中有很多元素。我不知道是什么问题。任何帮助表示赞赏。谢谢。
【问题讨论】:
-
您是否使用任何VPN,请停用并重新运行。
-
@JaydeepDevda 不,我不使用任何 VPN。而且它比“再次运行”要复杂一些,因为我每 2 天只有 3-5 分钟来测试我的代码,所以这就是我花了 2 周时间的原因。