soup.a.next_sibling.next_siblings
输出:
<generator object next_siblings at 0x03662E90>
返回的是迭代器,所以需要用一下语句输出:
for next in soup.p.next_siblings:
print next
BeautifulSoup标签树的遍历中,以下属性返回的都是迭代类型,需要用在for循环中。
.children
.descendants
.parents
.next_siblings
.previous_siblings
这篇博客探讨了Python的BeautifulSoup库在遍历标签树时如何使用迭代器。内容强调了由于`next_siblings`返回的是迭代器,因此需要通过循环来展开输出。
1万+

被折叠的 条评论
为什么被折叠?



