I'm trying to use R to scrape certain elements from a table on a website. I think I'm just making simple syntax errors, but I can't seem to figure out what I'm doing wrong.
Here's my code:
library(rvest)
library(string)
testlinkurl <- "https://www.pro-football-reference.com/boxscores/202209080ram.htm"
testlinkpage <- read_html(testlinkurl)
Here's what the page looks like:
...and here's the source code for it.
I'm trying to scrape the teams and the quarter scores from the table and put it into a csv. I've tried a few code snippets without success:
row <- html_attr(html_nodes(testlinkpage, xpath="//class="visitor center""))%>% html_table()
Error: unexpected symbol in "row <- html_attr(html_nodes(testlinkpage, xpath="//class="visitor"
row <- html_attr(html_nodes(testlinkpage, xpath="//*table[@class='statistics']"))
Warning message:
In xml_find_all.xml_node(x, make_selector(css, xpath)) :
Invalid expression [1207]
row <- html_attr(html_nodes(testlinkpage, xpath='/*[@id="content"]')) %>% html_table()
list()
Any and all input would be appreciated. Thank you!