相关疑难解决方法(0)

.text和.get_text()之间的差异

BeautifulSoup,.text和之间有什么区别.get_text()吗?

获取元素的文本应该首选哪一个?

>>> from bs4 import BeautifulSoup
>>>
>>> html = "<div>text1 <span>text2</span><div>"
>>> soup = BeautifulSoup(html, "html.parser")
>>> div = soup.div
>>> div.text
'text1 text2'
>>> div.get_text()
'text1 text2'
Run Code Online (Sandbox Code Playgroud)

html python beautifulsoup html-parsing

12
推荐指数
1
解决办法
4621
查看次数

标签 统计

beautifulsoup ×1

html ×1

html-parsing ×1

python ×1