.children
方法返回一个Python列表(请参阅最后一行包含的代码),而我想要的是soupy;如果我能得到一个bs4.BeautifulSoup对象,就可以在子对象上运行find
和其他操作。在
bs4.BeautifulSoup
似乎是唯一可以包含同级标记的对象。我如何得到一个糟糕的数据结构与孩子?在
In [123]: a._soup
Out[123]:
<div guppy-html="no-posts">There are <i>literally</i> no posts to show you</div>
<div><p guppy-html="text"></p></div>
In [120]: type(a._soup)
Out[120]: bs4.BeautifulSoup
In [129]: list(a._soup.children)
Out[129]:
[<div guppy-html="no-posts">There are <i>literally</i> no posts to show you</div>,
u'\n',
<div><p guppy-html="text"></p></div>]
目前没有回答
相关问题 更多 >
编程相关推荐