Using r to navigate and scrape a webpage with drop down html forms

后端 未结 1 1858
有刺的猬
有刺的猬 2021-01-13 16:35

I\'m attempting to scrape data from http://www.footballoutsiders.com/stats/snapcounts, but I can\'t change the fields in the drop down boxes on the site (\"team\", \"week\",

相关标签:
1条回答
  • 2021-01-13 17:11

    You can capture the session produced when the form is submitted and use that session as input to html_nodes:

    d <- submit_form(session=pgsession, form=filled_form)
    
    y <- d %>%
        html_nodes("table") %>%
        .[[2]] %>%
        html_table(header=TRUE)
    
    dim(y)
    #[1] 1695   11
    

    Otherwise, if you use read_html(url) you are reading the original page.

    0 讨论(0)
提交回复
热议问题