Rselenium-端口4445:连接被拒绝

时间:2018-08-02 20:48:42

标签: r docker web-scraping rselenium

我想使用R Selenium进行某些网络剪贴,但是出现连接错误。看一下简单的代码并输出:

library(devtools)
library(XML)
library(caTools)
library(binman)
library(wdman)
library(yaml)
library(wdman)
library(RSelenium)

> system('docker pull selenium/standalone-firefox')
Using default tag: latest
latest: Pulling from selenium/standalone-firefox
Digest: sha256:fcb896e8764e09af9e292e7acf2fc86030894ec667871086b5fe60704a82984d
Status: Image is up to date for selenium/standalone-firefox:latest
> system('docker run -d -p 4445:4444 selenium/standalone-firefox')
5d8ffbe34b8ede1d43dbf129ac1fed1cea1fdeadf314029e610d1ee0ac3c2562
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint goofy_newton (a1d52175b212280b1427c3ad77984bfd3826abeeef3bee0b2a9533618a4a712f): Bind for 0.0.0.0:4445 failed: port is already allocated.
> remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox")
> remDr$open()
[1] "Connecting to remote server"
Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused
> remDr$navigate("http://www.google.com")
Error in checkError(res) : 
  Undefined error in httr call. httr output: length(url) == 1 is not TRUE
> remDr$getTitle()
Error in checkError(res) : 
  Undefined error in httr call. httr output: length(url) == 1 is not TRUE

如何处理此错误? Docker Toolbox配置为使用我的IP。我正在使用ToolBox for Win 8.1

1 个答案:

答案 0 :(得分:1)

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint goofy_newton (a1d52175b212280b1427c3ad77984bfd3826abeeef3bee0b2a9533618a4a712f): Bind for 0.0.0.0:4445 failed: port is already allocated.

在我看来,您要映射的端口已绑定到某个进程。建议您使用netstat帮助并确定哪个进程正在占用端口。终止进程,然后尝试再次运行。