1

I'm sure a similar question has been answered previously, but I would love to understand why Rvest can't extract data from class = "section wrapper." I'm using R Studio and in short:

anasj_103 = read_html("https://www.hockey-reference.com/boxscores/201810030SJS.html")

ana_table = anasj_103 %>%
    html_node(xpath = '//*[@id="ANA_skaters"]') %>%
    html_table()

adv_ana = anasj_103 %>%
    html_node(xpath = '//*[@id="ANA_adv"]') %>%
    html_table()

Error that comes back: Error in UseMethod("html_table") : no applicable method for 'html_table' applied to an object of class "xml_missing"

The ana_table works fine when using the Xpath but the adv_ana gives an error or returns nothing when using a similar code.I run into this issue with all of the data that is in a div section followed by that class. Since I can't even return basic text in the section wrapper, I'm convinced this is the issue.

Any thoughts or workarounds?

1 Answers1

0

Thanks to QHarr for the assistance. The above question was solved by using:

table = anasjs_103 %>%
    html_nodes(xpath = '//comment()') %>%
    html_text() %>%
    paste(collapse = '') %>%
    read_html() %>%
    html_node('table#ANA_adv') %>%
    html_table()