2017-06-22 11 views
0

当Rselenium遇到此URL时,它会卡住,如果我切换到其他网页,它会好的。您可以看到下面的代码“getCurrentUrl”&“getPageSource”是最基本的操作。我无法在特定页面中使用R硒

url = "https://sycm.taobao.com/custom/login.htm?_target=http://sycm.taobao.com/" 


# Build up the environment ----------------------------------------------------- 
library(RSelenium) 
library(wdman) 
pDrv <- phantomjs(port = 4567L) 
remDr <- remoteDriver(browserName = "firefox", port = 4567L) 
remDr$open() 
remDr$navigate(url) 


#show the page ----------------------------------------------------------------- 

remDr$maxWindowSize() 
remDr$screenshot(display = TRUE) 

# basic operation by seleniumR 
remDr$getCurrentUrl() 
remDr$getPageSource()[[1]] 

回答

0

工程与谷歌浏览:

appUrl <- "https://sycm.taobao.com/custom/login.htm?_target=http://sycm.taobao.com/" 


# Build up the environment ----------------------------------------------------- 
library(RSelenium) 

rD <- rsDriver() 
remDr <- rD$client 
remDr$navigate(appUrl) 


#show the page ----------------------------------------------------------------- 

remDr$screenshot(display = TRUE) 

# basic operation by seleniumR 
remDr$getCurrentUrl() 
remDr$getPageSource()[[1]] 

rm(rD) 
gc() 

而对于Firefox的:

appUrl <- "https://sycm.taobao.com/custom/login.htm?_target=http://sycm.taobao.com/" 
# Build up the environment ----------------------------------------------------- 
library(RSelenium) 

rD <- rsDriver(browser = "firefox") 
remDr <- rD$client 
remDr$navigate(appUrl) 

#show the page ----------------------------------------------------------------- 

remDr$maxWindowSize() 
remDr$screenshot(display = TRUE) 

# basic operation by seleniumR 
remDr$getCurrentUrl() 
remDr$getPageSource()[[1]] 
rm(rD) 
gc() 
+0

如果我用你的方式,这种错误如下再次表明,我试过很多次去解决它,但失败了,我选择了另一种使用Rselenium的方法,这也是我在这里找到的。如果您对此有相当的经验,请帮忙。 ------------------------------------------------ -------------------------------------------- RD < - rsDriver( ) 检查Selenium服务器版本: BEGIN:PREDOWNLOAD 错误open.connection(CON, “RB”):无法连接到服务器 – jeremyparty

+0

嘿。当你来到 remDr $ getCurrentUrl仍然卡住() remDr $ getPageSource()[1]。你只是改变了浏览器。 – jeremyparty

+0

似乎是phantomjs的问题。提高项目页面https://github.com/ariya/phantomjs/issues – jdharrison