Error using rsDriver of the RSelenium package in R

huangapple go评论68阅读模式
英文:

Error using rsDriver of the RSelenium package in R

问题

我正在尝试在R中使用RSelenium包来打开一个浏览器。

使用以下命令时:

rs_driver_object <- rsDriver(browser="chrome", 
                             chromever = "113.0.5672.63",
                             verbose = F,
                             port=free_port())

我收到以下错误消息:

Error in gsub("\\s+", ",", ActiveConnections) : input string 1 is invalid
In addition: Warning message:
In gsub("\\s+", ",", ActiveConnections) :
  unable to translate '  Proto  Adresse locale         Adresse distante       <90>tat' to a wide string

这是我的代码的前几行,它们工作得很好:

library(tidyverse)
library(RSelenium)
library(netstat)
library(wdman)

# 下载chromedriver
selenium()

# 查找chromedriver的安装位置
selenium_object <- selenium (retcommand = T, check = F)

# 要使用的版本
binman::list_versions("chromedriver")

这是我的Google Chrome版本:113.0.5672.127

这是带有binman的行的结果:

$win32
 "113.0.5672.24" "113.0.5672.63" "114.0.5735.16"

所以使用chromedriver的版本113.0.5672.63应该可以工作。

我认为错误来自于free_port()函数,它允许我找到一个空闲的端口。我尝试过不使用它,但如果我不指定要使用的端口,或者使用一个随机端口,它可能会告诉我该端口已经被使用,因此无法工作。我希望找到一种每次都能正常工作的方法,所以free_port()可能是一个不错的选择,如果它能正常工作的话。

英文:

I am trying to open a browser using the RSelenium package in R.

When using this command

rs_driver_object &lt;- rsDriver(browser=&quot;chrome&quot;, 
                             chromever = &quot;113.0.5672.63&quot;,
                             verbose = F,
                             port=free_port())

I get this error

Error in gsub(&quot;\\s+&quot;, &quot;,&quot;, ActiveConnections) : input string 1 is invalid
In addition: Warning message:
In gsub(&quot;\\s+&quot;, &quot;,&quot;, ActiveConnections) :
  unable to translate &#39;  Proto  Adresse locale         Adresse distante       &lt;90&gt;tat&#39; to a wide string

Here are the first lines of my code, they work well

library(tidyverse)
library(RSelenium)
library(netstat)
library(wdman)

# To download chromedriver
selenium()

# To find where chromedriver is installed
selenium_object &lt;- selenium (retcommand = T, check = F)

# Versions to use
binman::list_versions(&quot;chromedriver&quot;)

Here is my Google Chrome version : 113.0.5672.127

and here is the result of the line with binman :

$win32
 &quot;113.0.5672.24&quot; &quot;113.0.5672.63&quot; &quot;114.0.5735.16&quot;

So using the 113.0.5672.63 version of chromedriver should work.

I think the error comes from free_port() which allows me to find a free port. I have tried not to use but if I don't say which port I'm using or if I use a random port, it can tell me that the port is already in use and so it doesn't work. I would like something that works every time, so free_port() would be a good fit if it would work.

答案1

得分: 1

我遇到了同样的问题。这不是RSelenium包的问题,而是在netstat中。我在命令提示符中键入了netstat -s -p tcp,发现统计信息是以我的本地语言显示的。在开发人员解决此问题之前,您需要将操作系统的语言更改为英语。

英文:

I came across the same problem. It isn't a problem in the RSelenium package, it's in the netstat. I've typed netstat –s –p tcp in my command prompt and saw that the statistics were coming out in my local language. Until developers resolve this, you've to change your OS language to English.

huangapple
  • 本文由 发表于 2023年5月28日 22:31:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76351996.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定