I am uisng R
in RStudio
and I have an R
script which performs web scraping. I am stuck with an error message when running these specific lines:
review<-ta1 %>%
html_node("body") %>%
xml_find_all("//div[contains@class,'location-review-review']")
The error message is as follows:
xmlXPathEval: evaluation failed
Error in `*tmp*` - review : non-numeric argument to binary operator
In addition: Warning message:
In xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = Inf) :
Invalid predicate [1206]
Note: I have dplyr
and rvest
libraries loaded in my R
script.
I had a look at the answers to the following question on StackOverflow
:
Non-numeric Argument to Binary Operator Error
I have a feeling my solution relates to the answer provided by Richard Border to the question linked above. However, I am having a hard time trying to figure out how to correct my R
syntax based on that answer.
Thank you for looking into my question.
Sample of ta1 added:
{xml_document}
<html lang="en" xmlns:og="http://opengraphprotocol.org/schema/">
[1] <head>\n<meta http-equiv="content-type" content="text/html; charset=utf-8">\n<link rel="icon" id="favicon" ...
[2] <body class="rebrand_2017 desktop_web Hotel_Review js_logging" id="BODY_BLOCK_JQUERY_REFLOW" data-tab="TAB ...