简体   繁体   English

Python Selenium Geckodriver Connection拒绝了

[英]Python Selenium Geckodriver Connection refused

I spent hours trying to make Selenium works with Python no luck this error message selenium.common.exceptions.WebDriverException: Message: connection refused this is the example I have used:- 我花了几个小时试图使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()

This is depence I intalled apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic 这是我所说的apt-get install -y xorg xvfb dbus-x11 xfonts-100dpi xfonts-75dpi xfonts-cyrillic

This is /root/geckodriver.log output 这是/root/geckodriver.log输出

1493938773101 geckodriver INFO Listening on 127.0.0.1:40876 1493938774156 geckodriver::marionette INFO Starting browser /usr/lib/firefox/firefox.sh with args ["-marionette"] (firefox:3128): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed 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'失败

I'm running Selenium on Ubuntu 14.04 64-bit VPS remote server with 128MB RAM I can't figure out what's make Selenium not able to communicate with browsers drivers both Chrome and Firefox. 我在Ubuntu 14.04 64-bit VPS远程服务器上使用128MB RAM运行Selenium我无法弄清楚是什么让Selenium无法与Chrome和Firefox的浏览器驱动程序进行通信。

Please start with checking your "firefox" browser version. 请先查看“firefox”浏览器版本。

I found it very confusing at some point. 我发现它在某些方面非常令人困惑。 I'm using the Raspbian and the "Iceweasel" downloaded with apt-get was a Firefox 52 version which didn't work with geckodriver 0.19 (this one requires Firefox 55 or greater). 我正在使用Raspbian,使用apt-get下载的“Iceweasel”是一个Firefox 52版本,它与geckodriver 0.19不兼容(这个需要Firefox 55或更高版本)。

What worked for me was to download geckorvider v0.16 and that resolved the problem. 对我有用的是下载geckorvider v0.16并解决了这个问题。

Whats moreover, you probably don't need xorg to make it work, the only packages I needed was xfvb and iceweasel. 此外,你可能不需要xorg来使它工作,我需要的唯一包是xfvb和iceweasel。

Ok, I gave up on Geckodriver and I use PhantomJS as my webdriver. 好吧,我放弃了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()

Here are the steps I used to install PhantomJS : 以下是我用于安装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

See also How to install PhantomJS on Ubuntu . 另请参见如何在Ubuntu上安装PhantomJS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium Python selenium.common.exceptions.WebDriverException:消息:使用geckodriver和firefox拒绝连接 - Selenium Python selenium.common.exceptions.WebDriverException: Message: connection refused using geckodriver and firefox selenium.common.exceptions.WebDriverException:消息:Raspberry Pi debian上的GeckoDriver Firefox和Selenium拒绝连接错误 - selenium.common.exceptions.WebDriverException: Message: connection refused error with GeckoDriver Firefox and Selenium on Raspberry Pi debian Python Selenium 和 FireFox \\ geckodriver - Python Selenium and FireFox \ geckodriver Python 3:Selenium和geckodriver错误? - Python 3: Selenium & geckodriver error? 硒(python):Errno 101连接在屏幕截图上被拒绝? - selenium (python): Errno 101 Connection Refused on screenshot? Python Selenium show geckodriver版本 - Python Selenium show geckodriver version Python Selenium 路径中需要壁虎驱动程序 - Python Selenium geckodriver required in path selenium.common.exceptions.WebDriverException:消息:尝试通过Raspberry-pi3中的GeckoDriver打开Firefox浏览器时连接被拒绝 - selenium.common.exceptions.WebDriverException: Message: connection refused while trying to open Firefox browser through GeckoDriver in Raspberry-pi3 Python Selenium Geckodriver 应该在 PATH 中 - Python Selenium Geckodriver should be in PATH Selenium python,多个 geckodriver 实例 - Selenium python, multiple geckodriver instances
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM