gpt4 book ai didi

python - 如何使用lxml从html文件中提取python中的段落文本?

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:01 24 4
gpt4 key购买 nike

我正在尝试提取该段落,但得到 [<Element p at 0x7f8c81a26548>]而不是段落。如何提取该段落?

Selector_1 = "div.bloco-imovel-texto p"
tree.cssselect(Selector_1)
<div class="bloco-imovel-texto">
<h3 class="lbl_description">
Description </h3>
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia
animi, id est laborum et dolorum fugaEt harum quidem rerum facilis est et expedita distinctio.Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est,
omnis dolor repellendus.</p>
</div>

最佳答案

一定是

tree.cssselect(Selector_1)[0].text

关于python - 如何使用lxml从html文件中提取python中的段落文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54451561/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com