[英]Firefox is crashing and I am getting ConnectionResetError when used Python with Selenium
I started working on a python script that is going to navigate through a webpage and going to take some necessary datas for me. 我开始研究一个python脚本,该脚本将浏览网页并为我获取一些必要的数据。
I found a code that uses selenium in it to navigate the internet. 我找到了一个在其中使用硒的代码来浏览互联网。
The problem is, when I run the code, Firefox is crashing and I am getting the ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host error. 问题是,当我运行代码时,Firefox崩溃了,并且我得到了ConnectionResetError:[WinError 10054]现有连接由于远程主机错误而被强制关闭 。
I couldn't find the glitch and need a help. 我找不到故障,需要帮助。
Here is the code. 这是代码。
from selenium import webdriver
# initiate
driver = webdriver.Firefox() # initiate a driver, in this case Firefox
driver.get("URL_HERE") # go to the url
# log in
username_field = driver.find_element_by_name(Username_here) # get the username field
password_field = driver.find_element_by_name(Password_here) # get the password field
username_field.send_keys("...") # enter in your username
password_field.send_keys("...") # enter in your password
password_field.submit() # submit it
# print HTML
html = driver.page_source
print (html)
For those who wants to have an answer, 47 versioned Firefox browsers have a problem with this. 对于那些想知道答案的人,47种版本的Firefox浏览器对此有问题。 So I've tried to owrk with a lower version then 47 and it worked. 因此,我尝试使用低于47的较低版本进行操作,并且效果良好。
I'd suggest if it is not necessary, use Chrome. 我建议如果不需要,请使用Chrome。 (First you need to download the driver) That way you are not going to stuck with something like this. (首先,您需要下载驱动程序)这样,您就不会陷入类似这样的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.