RSelenium:抓取一个完整的可扩展表 [英] RSelenium: scraping a FULL expandable table
本文介绍了RSelenium:抓取一个完整的可扩展表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基于这个问题,OP想要从这个页面中抓取所有控股"表 - 向下滚动到黄色部分.该表显示前 10 行,但可以扩展到更多行.
Based off this question, the OP wants to scrape the table "All Holdings," from this page - scroll down to the yellow part. The table shows the first 10 rows, but can expand to quite a few more.
当我们想要整个表时,我的 rvest
和 RSelenium
解决方案都只取前 10 行.我的代码:
Both of my rvest
and RSelenium
solutions only take the first 10 rows, when we want the entire table. My code:
注册码
library(tidyverse)
library(rvest)
etf_url <- "http://innovatoretfs.com/etf/?ticker=ffty"
etf_table <- etf_url %>%
read_html %>%
html_table(fill = T) %>%
.[[5]]
RSelenium 代码
library(RSelenium)
library(rvest)
remDr <- remoteDriver(port = 4445L, remoteServerAddr = "localhost",
browserName = "chrome")
remDr$open()
remDr$navigate("http://innovatoretfs.com/etf/?ticker=ffty")
page <- read_html(remDr$getPageSource()[[1]])
table <- html_table(page, fill = TRUE, header = T)
table[[5]]
我们怎样才能得到 FULL 表?谢谢.
How can we get the FULL table? Thanks.
推荐答案
以下应该扩展表格 - 没有在 Selenium 中测试它,但它应该可以工作.
Following should expand the table - didn't test it in Selenium but it should work.
remDr$executeScript("__doPostBack('ctl00$BodyPlaceHolder$ViewHoldingsLinkButton','')", args = list())
这篇关于RSelenium:抓取一个完整的可扩展表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文