1
中的html_nodes定义XPATH值作为变量,我需要将该XPATH值定义为html_nodes中的变量。以便我可以遍历许多XPATH。当我在外面定义XPATH时,它会抛出错误(例如,当xpath = // * [@ id =“banner”])时出现错误。能否请你帮忙。 我的代码:如何使用R(rvest)在网页报废时使用R
xpath <- as.character('//*[@id="title-overview-widget"]')
name <- lego %>%
html_nodes(xpath) %>%
html_text()
Error Message : Error in tokenize(css) : Unexpected character '/' found at position 1
非常感谢MrFlick。现在它工作正常。 – Solomon