【发布时间】:2021-04-23 21:41:44
【问题描述】:
似乎contains(text(), 'TARGET_STRING') 与html_nodes 以及“或运算符”:“|”可以正常工作,但不能一起工作。
可重现的例子:
html <- "<a>a</a><p>abc</p>"
xp <- "//*[self::a|self::b]" # or operator works
xp2 <- "//*[contains(text(),'abc')]" # contains text works
# but it doesnt work together
xp3 <- "//*[self::a|contains(text(),'abc')]"
html_nodes(x = read_html(html), xpath = xp)
html_nodes(x = read_html(html), xpath = xp2)
# this one fails
html_nodes(x = read_html(html), xpath = xp3)
【问题讨论】: