Python Selenium Geckodriver连接被拒绝

塞勒姆

我花了数小时试图使Selenium与Python配合使用,但运气不好,selenium.common.exceptions.WebDriverException: Message: connection refused这是我使用的示例错误消息:-

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()
browser.get('http://www.python.org')
browser.close()

我说过的就是这种依赖 apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic

这是/root/geckodriver.log输出

1493938773101 geckodriver INFO侦听127.0.0.1:40876 1493938774156 geckodriver :: marionette INFO使用args [“ -marionette”]启动浏览器/usr/lib/firefox/firefox.sh(firefox:3128):GLib-GObject-CRITICAL **: g_object_ref:断言'object-> ref_count> 0'失败

我在Ubuntu 14.04 64-bit具有128MB RAM的VPS远程服务器上运行Selenium,但我不知道Selenium无法与Chrome和Firefox浏览器驱动程序通信的原因。

塞勒姆

好的,我放弃了,Geckodriver并使用PhantomJS了我的webdriver。

 from selenium import webdriver  
 display = Display(visible=0, size=(800, 600))
 display.start() 
 driver = webdriver.PhantomJS()
 driver.get('http://www.python.org')
 html_source = driver.page_source
 print ("html_source:",html_source) 
 driver.quit()

这是我用来安装PhantomJS的步骤:

cd ~
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2
mv $PHANTOM_JS /usr/local/share
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin



Python  Selenium        
apt-get install python-pip  -y 
pip uninstall pyvirtualdisplay
apt-get install x11vnc xvfb fluxbox
Xvfb :99 -ac
xvfb-run  -a   python 99.py
pip uninstall selenium
pip install selenium==2.53.1

另请参阅如何在Ubuntu上安装PhantomJS

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

初始化Selenium WebDriver时如何解决python-Selenium错误“连接被拒绝”?

IOError:[Errno 13]权限被拒绝:运行Python / Selenium时'geckodriver.log

无法通过Jenkins中的Selenium Maven使用GeckoDriver Firefox与WindowServer错误建立默认连接

在Mac OS X上尝试通过GeckoDriver和Selenium使用firefoxprofile时,“未知错误”,“消息”:“连接被拒绝”,“堆栈跟踪”

selenium:socket.error:[Errno 61]连接被拒绝

python Selenium PermissionError:[WinError 5]访问被拒绝

权限被拒绝:在python中运行Selenium Webdriver时出现“ geckodriver.log”

Selenium / Python:JavaScript href拒绝执行

Selenium Python selenium.common.exceptions.WebDriverException:消息:使用geckodriver和firefox拒绝连接

WebDriverException:消息:浏览器似乎已经退出,然后才能使用GeckoDriver Selenium和Python连接错误

更改Geckodriver for Python Selenium的日志级别

selenium.common.exceptions.WebDriverException:消息:尝试通过Raspberry-pi3中的GeckoDriver打开Firefox浏览器时连接被拒绝

如何从python selenium firefox webdriver获取geckodriver版本?

Selenium-socket.error:[Errno 111]连接被拒绝

Selenium远程Webdriver错误(连接被拒绝)

selenium.common.exceptions.InvalidSessionIdException使用GeckoDriver通过Python在无头模式下使用Selenium Firefox

拒绝连接并轮询更改失败:尝试使用Selenium GeckoDriver和Firefox提取资源错误时出现NetworkError

无法使用Python和geckodriver在Raspbian下运行selenium-webdriver

网站是否可以拒绝来自Python Selenium脚本的访问?

将Scrapy与Selenium结合使用时连接被拒绝

Selenium、Firefox 和 GeckoDriver

使用 python selenium 和 geckodriver 拒绝连接(操作系统错误 111)

SessionNotCreatedException:消息:使用 Python 将 geckodriver 用于 Selenium 时权限被拒绝(在 Windows 10 中)

如何使用selenium geckodriver收集数据python

org.openqa.selenium.WebDriverException:通过 Selenium v3.4.0 和 geckodriver-v0.20.1 启动 Firefox Browser 45.0.1 时连接被拒绝

Selenium 的 htmlunit webdriver 导致错误 10061,连接被主动拒绝

Laravel Sail + Dusk + Selenium:连接被拒绝

几次成功的 Selenium Geckodriver 任务(Python)后连接被拒绝(操作系统错误 111)

使用 selenium/geckodriver 的 DeprecationWarning