How to pass an xpath to html_nodes()?

Viewed 3807

I want to use html_nodes to scrape organizations' names from the google search results (I need the first element only, assuming that that's gonna be the best guess). Right now, I am trying to target the first result using its xpath, and passing it to the function html_nodes. To find the xpath, I am using google chrome as in the pic below enter image description here

Which gives me //*[@id="rso"]/div[1]/div/div[1]/div/div/h3/a as an xpath for the title of the first result. However, when I try to pass it to html_nodes() I get an empty string:

page %>% html_nodes(xpath='//*[@id="rso"]/div[1]/div/div[1]/div/div/h3/a')
{xml_nodeset (0)}

While I would expect the string The A-Test 2017 Workshop.

How can I get the content of that a tag either with xpath or css?

1 Answers
Related