我是新来的美丽汤,我试图提取的信息,出现在一个页面上。这个信息包含在div^{cl1}$
table = soup.findAll('div', {'class': '_50f3'})
[<div class="_50f3">Lives in <a class="profileLink" data-hovercard="/ajax/hovercard/page.php?id=114148045261892" href="/Fort-Worth-Texas/114148045261892?ref=br_rs">Fort Worth, Texas</a></div>,
<div class="_50f3">From <a class="profileLink" data-hovercard="/ajax/hovercard/page.php?id=111762725508574" href="/Dallas-Texas/111762725508574?ref=br_rs">Dallas, Texas</a></div>]
例如,在上面我想存储“Lives in”:“Fort Worth,Texas”和“From”:“Dallas,Texas”。但在最一般的情况下,我想存储任何信息有在那里。你知道吗
非常感谢您的帮助!你知道吗
在一般情况下,这只是您需要的^{} —它将通过子节点递归地构造一个元素文本字符串:
但是,也可以分别提取标签和值:
印刷品:
应该有用
相关问题 更多 >
编程相关推荐