【发布时间】:2017-03-16 13:08:11
【问题描述】:
<li class="actualPrice price fakeLink " data-automation="actual-price">
<span class="visuallyhidden">Hello world</span>
Some text I want to extract
</li>
这里有一些 HTML。 我想提取文本“我想提取的一些文本”,我不想提取 Hello world。
我尝试过类似 find('span') 并使用 next_sibling 但我没有。
for a in soup.find_all('li', 'actualPrice'):
print a.get_text()
这给了我 Hello world 和“我想提取的一些文本”。 有没有只提取“我想提取的一些文本”的方法?
【问题讨论】:
-
a.span.next.next会给你Some text I want to extract
标签: python html beautifulsoup