硒 |获取youtube页面源 [英] rselenium | get youtube page source
本文介绍了硒 |获取youtube页面源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 youtube.com 的页面源无法抓取?
Why is the page source of youtube.com not scrapeable?
我尝试了以下操作(使用 phantomjs 以及带有硒服务器的 chrome)
I tried the following (using phantomjs as well as chrome with a selenium server)
library(RSelenium)
pJS <- phantom(pjs_cmd = ...)
Sys.sleep(5) # give the binary a moment
remDr <- remoteDriver(browserName = 'phantomjs')
remDr$open()
remDr$navigate("https://www.youtube.com/")
remDr$getTitle()[[1]] # [1] "YouTube"
remDr$getPageSource()
返回:
Error in fromJSON(content, handler, default.size, depth, allowComments, :
invalid JSON input
推荐答案
这是编码问题.暂时使用开发版本,直到下一个版本发布到 CRAN:
Its an issue with encoding. Use the dev version for now until the next version is released to CRAN:
devtools::install_github("ropensci/RSelenium")
这篇关于硒 |获取youtube页面源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文