<li class="actualPrice price fakeLink " data-automation="actual-price">
<span class="visuallyhidden">Hello world</span>
Some text I want to extract
</li>
这里有一些HTML。 我想提取文本“sometextextract”,而不是提取helloworld。在
我尝试过find('span')和使用next-sibling,但是没有。在
^{pr2}$这给了我“你好世界”和“我想提取的一些文本”。 有没有什么方法只提取“我想提取的一些文本”?在
为了使用另一种方法,您可以使用
stripped_strings
:输出:
如果要提取
span
标记后的下一个元素,则可以使用.next
:相关问题 更多 >
编程相关推荐