coderLMN

Results 85 comments of coderLMN

这个问题在前面的 [说明:书中的一些示例代码只能作为参考](https://github.com/coderLMN/AutomatedDataCollectionWithR/issues/3#issue-154843065) 里提到了: > 大家都知道,对于活跃的网站来说,定期改版页面是必须的。因此网页结构的变化也不可避免。本书中的代码只是根据在某个时间点对网页结构进行的分析而编写的,并不等于这些代码是长期有效的。 > > 比如在第一章,濒危文化遗产地的维基百科网址 http://en.wikipedia.org/wiki/List_of_World_Heritage_in_Danger 用 htmlParse() 函数就会报错,这是因为维基百科已经启用了 https 安全协议,因此需要证书才能访问,读者可以参考 9.1.7 "通过 HTTPS 进行的连接" 中的内容,对原书代码进行修改。 可以考虑两种做法: 1. 如果有一些技术基础的话,可以先往后阅读 9.1.7 的相关内容,然后再尝试修改代码; 2. 不然的话,可以上网找一个有类似结构的网站,这样只需对示例代码进行微小的修改。

噢,真的!我都没有注意。 @psaxcode 非常感谢提供这个信息,谢谢! @GreenEric 可以参考一下。

```R danger_table$scrit NULL ``` 说明你前面的代码执行不成功,没有取到正确的表格。我看到的 danger_table$crit 内容是这样的: ```R > danger_table$crit [1] "Cultural:\n(iv)" "Natural:\n(vii), (ix), (x)" [3] "Cultural:\n(iii)(iv)" "Cultural:\n(i)(iii)(vi)" [5] "Cultural:\n(i)(ii)(iii)(iv)(vi)" "Cultural:\n(iii)(iv)(v)" [7] "Cultural:\n(iii), (iv)" "Cultural:\n(iv)" [9] "Natural:\n(vii), (ix), (x)" "Cultural:\n(i),...

从这里看不出原因,你可以先看一下 yend_clean 的内容是否正常。

看了一下你贴的错误信息: > java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases...

可以在官网下载这个 [v2.53.1](https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar) 版,亲测有效。 我刚刚还在本书的 [GitHub Page](http://coderlmn.github.io/AutomatedDataCollectionWithR/) 上放了一个我以前下载过的 [v2.53.0](http://coderlmn.github.io/AutomatedDataCollectionWithR/selenium-server-standalone-2.53.0.jar) 版,也可以用这个。

这里的关键错误信息是这一条: > **org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.** 我去查了一下这个错误,貌似是因为你的 Firefox 的版本(48.0.2)和 Selenium 2.53.0 版本不兼容。这两个软件之间不同版本的兼容性问题一直广为诟病。 参考[这篇文章](http://seleniumsimplified.com/2016/06/use_selenium_webdriver_jar_locally/) 里说的,对应 Selenium 2.53 ,Firefox 47.0.1 应该是能工作的,你可以在 Mozilla [官方网站](https://www.mozilla.org/en-US/firefox/47.0.1/releasenotes/)...

这个问题比较少见,我没查到原因。上次碰到一个 iFrame 的问题,发现书里面这个 Rwebdriver 组件是该书的作者之一 C. Rubba 编写的,我个人觉得它做得并不好,而且自从三年前提交后就没有再更新过,文档也基本空白。后来我就改用 RSelenium 组件 (可以参考这个 [讨论](https://github.com/coderLMN/AutomatedDataCollectionWithR/issues/2#issuecomment-218971586)),不再用它了。你这次碰到这个问题,我怀疑和 Rwebdriver 组件也有关系,所以我推荐你也换成 RSelenium 。它的文档可以参阅:https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html 。 --- 另外我今天还试了一下 Selenium 3.0.1 版,需要先下载 [geckodriver驱动](https://github.com/mozilla/geckodriver/releases),解压到某个路径(比如 ./Downloads ),然后在运行 Selenium 的命令行里加上这个路径作为 `webdriver.gecko.driver` 参数即可: ```...