我刚刚浏览了 B4 文档并获得了一些Going back and forth关于html family tree.
last_a_tag = soup.find("a", id="link3")
last_a_tag
# <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>
last_a_tag.next_element
# u'Tillie'
last_a_tag.previous_element
# u' and\n' ## upto this is Good to understand!
last_a_tag.previous_element.next_element
# <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>
冲突在这里浮现在我的脑海中。根据.Previous_element概念last_a_tag.previous_element.next_elementt应该给出<a class="sister" href="http://example.com/tillie" id="link3">但为什么如上所示的完整?
编辑
last_a_tag.previous_element
# u' and\n' <~~Perfect
last_a_tag.previous_element.next_element
# <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>
为什么不到下面呢?
#<a class="sister" href="http://example.com/tillie" id="link3">
怎么到下面的部分?
Tillie</a> <~~这里是混乱
帮助我理解。