文章详情页
python的bs4如何筛选出h1标签中的内容
浏览:310日期:2022-09-15 13:55:06
问题描述
今天在学习bs4的解析html中 发现有解析各种标签中的内容的语句,但是未找到能解析出h1 h2 h3 h4这些标签中的文字的语句和参数啊,请问该如何进行筛选呢?
问题解答
回答1:>>> from bs4 import BeautifulSoup>>> html = ''' <html> <h1 align='center'>This is heading 1</h1> </html> '''>>> soup = BeautifulSoup(html,’html.parser’)>>> res = soup.find(’h1’).get_text()>>> print(res)This is heading 1
像这样吗?
回答2:h1.string
相关文章:
1. ionic 项目 ionic build android -release 打包时报错2. python3.x - python3.5.2安装时make报错求助3. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?4. javascript - vue组件通过eventBus通信时,报错a.$on is not a function5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. mac里的docker如何命令行开启呢?7. angular.js - 如何控制ngrepeat输出的个数8. html - vue项目中用到了elementUI问题9. python - 如何用pandas处理分钟数据变成小时线?10. html5 - weex H5端的使用,怎么跑起来?
排行榜

网公网安备