我該如何去並行運行RSelenium
。並行運行RSelenium
以下是並聯
library(RSelenium)
library(rvest)
library(magrittr)
library(foreach)
library(doParallel)
URLsPar <- c("http://www.example.com/", "http://s5.tinypic.com/n392s6_th.jpg", "http://s5.tinypic.com/jl1jex_th.jpg",
"http://s6.tinypic.com/16abj1s_th.jpg", "http://s6.tinypic.com/2ymvpqa_th.jpg")
(detectCores() - 1) %>% makeCluster %>% registerDoParallel
ws <- foreach(x = 1:length(URLsPar), .packages = c("rvest", "magrittr", "RSelenium")) %dopar% {
URLsPar[x] %>% read_html %>% as("character")}
stopImplicitCluster()
打開使用'的open'方法爲每個實例單獨的瀏覽器'remoteDriver'類。在你的工作流程中,「seleniumPipes」可能是合適的https://github.com/johndharrison/seleniumPipes – jdharrison
我有幾千個網址,可以說我有3個內核'registerDoParallel',我需要'打開'3 「foreach」之前的實例?我不知道'seleniumPipes'! thnx –