扫码关注官方订阅号
extract
markup = '<a href="http://example.com/">I linked to <i>example.com</i></a>' soup = BeautifulSoup(markup) text = soup.i.get_text() i_tag = soup.i.extract() text # example.com i_tag # <i>example.com</i>
譬如这样p = soup.find("p",class_="xxx")p.contents会返回p里面的内容,而且是一个列表。
beautiful soup doc里面的find()method
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
extract
譬如这样
p = soup.find("p",class_="xxx")
p.contents会返回p里面的内容,而且是一个列表。
beautiful soup doc里面的find()method