docker - 为什么我在 Docker 中遇到 RSelenium 语法错误?
问题描述
我正在尝试遵循本教程RSelenium 和抓取,因为它似乎正是我想要做的。使用 RSelenium 抓取 Javascript 网站。
我已经安装了 Docker,一切看起来都很好,但是我遇到了以下命令的问题:
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox'")
我认为应该是:
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox")
但是,两个版本都返回此错误:
bash: syntax error near unexpected token `('
我究竟做错了什么?
这是完整的日志:
Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
graha@LAPTOP-SWIFT MINGW64 /c/Program Files/Docker Toolbox
$ docker pull selenium/standalone-chrome Using default tag: latest
latest: Pulling from selenium/standalone-chrome
Digest: sha256:d46e05c47bad20ec4ad675368fa1b7addb6c9529e8fdc23f5eb55629235b8e14
Status: Image is up to date for selenium/standalone-chrome:latest
graha@LAPTOP-SWIFT MINGW64 /c/Program Files/Docker Toolbox
$ docker run -d -p 4445:4444 selenium/standalone-chrome fbb8c9145e92789f6941cc04fb74d216d43aed178825c1698ede2644589c715f
graha@LAPTOP-SWIFT MINGW64 /c/Program Files/Docker Toolbox
$ remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "chrome")
bash: syntax error near unexpected token `('
graha@LAPTOP-SWIFT MINGW64 /c/Program Files/Docker Toolbox
$
谢谢。
解决方案
您的基本问题是您尝试在 bash shell 提示符下键入 R 命令,而这永远不会起作用。我认为您可能错过了您所遵循的教程的要点:
您使用的 Docker 映像仅提供 Selenium,这是一种用于远程控制 Web 浏览器的工具。预计您在主机上运行 R,并将 RSelenium 库指向 Docker 容器提供的 selenium 服务。
您需要在主机上安装 R 才能学习该教程。
推荐阅读
- flutter - Flutter:如何处理图像/文件空路径的异常?
- android - 我正在尝试在模拟器上使用网络摄像头,但在 Android Studio 上“被信号 6 中断:SIGABRT 错误”
- c++ - 允许编译带有复合语句的代码是 gcc 错误吗?
- asp.net - 通过 WCF 发送客户端证书导致错误:“客户端身份验证方案‘匿名’禁止 HTTP 请求”
- php - 有没有办法在 PHP 中处理图表?
- php - Laravel 序列化数据的总和值
- javascript - 如何有条件地解构对象?
- android - Android Splash Screen doesn't display
- c# - 在 C# 中,我试图显示上一个 WriteLine 方法中的文本字符串。得到编译器错误
- python - 使用请求模块来使用 API?