2017-08-10 102 views
0

加载更多按钮刮网站我试图用加载更多按钮刮网站。我已经通过使用Windows提示设置了一个硒服务器。 Selenium服务器正在运行,但是当我在R中运行脚本时,我仍然收到以下错误。我已经写了很多博客文章并试图找到答案,但我缺乏技术知识来解决这个问题,所以我希望有人愿意帮助我。与R(Rvest)

错误

[1] "Connecting to remote server"

Selenium message: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

Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. class: java.lang.IllegalStateException Further Details: run errorDetails method

Windows提示

cd c:\selenium 
java -Dwebdriver.chrome.driver=c:\geckodriver\chromedriver.exe - 
Dwebdriver.gecko.driver.driver=c:\geckodriver\geckodriver.exe -jar selenium- 
server-standalone-3.4.0.jar 

[R SCRIPT

library(rvest) 
library(RSelenium) 
library(stringr) 
library(xm12) 
library(wdman) 
url <- "https://www.social-enterprise.nl/wie-doen-het/" 

remDr <- remoteDriver() 
# Open the browser webpage 
remDr$open() 

#navigate to your page 
remDr$navigate(url) 

# Locate the load more button 
loadmorebutton <- remDr$findElement(using = 'css selector', "#morenews") 

for (i in 1:2){ 
    print(i) 
    loadmorebutton$clickElement() 
    Sys.sleep(30) 
} 
page_source<-remDr$getPageSource() 

Merken <- read_html(page_source[[1]]) %>% 
    html_nodes("#membershipCntr span") %>% 
    html_text() 
remDr$close() 

回答

0

你缺少一些选项远程网络驱动程序实例化。你可以尝试下面的代码,

remDr <- remoteDriver(remoteServerAddr = "localhost" 
         , port = 4444L 
         , browserName = "firefox" 
        ) 
+0

我试过了代码,但是我仍然得到相同的错误信息。我不明白,因为我已经设置了壁虎驱动程序的路径。 – gvkleef