标签,但在嵌套标签之前?
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
CSS 选择器无法到达裸文本节点。
然而,这对于 XPath 来说是微不足道的,如果您使用像 Nokogiri 这样的网络抓取工具或像 Selenium 这样的测试工具,您可以使用它:
//p/text()[following-sibling::a][1]