博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7.01-beautiful_soup2
阅读量:4477 次
发布时间:2019-06-08

本文共 632 字,大约阅读时间需要 2 分钟。

# pip install beautifulsoup4from bs4 import BeautifulSouphtml_doc = """The Dormouse's story

The Dormouse's story

Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.

"""# 1.转类型 bs4.BeautifulSoup'soup = BeautifulSoup(html_doc, 'lxml')# print(type(soup))# 2. 解析数据# Tag 标签对象 bs4.element.Tag'result = soup.head# 注释的内容 类型 'bs4.element.Comment'result = soup.p.stringprint(type(result))result = soup.a# 内容 Navigablestring 'bs4.element.NavigableStringresult = soup.a.string# 属性result = soup.a['href']

 

转载于:https://www.cnblogs.com/hankleo/p/10626384.html

你可能感兴趣的文章
最简陋的python数据
查看>>
第一堂java web课
查看>>
操作系统简介
查看>>
第1周小组博客作业--1703班06组
查看>>
vue项目中icon图标的完美引入
查看>>
C语言指针
查看>>
Java的安装
查看>>
0920 JSON数据 蓝懿
查看>>
Azure Cosmos DB 使用费用参考
查看>>
【嵌入式开发】写入开发板Linux系统-模型S3C6410
查看>>
C# 子线程与主线程通讯方法一
查看>>
006——修改tomacat的编码
查看>>
《C程序设计语言》笔记 (八) UNIX系统接口
查看>>
git常用命令
查看>>
Android必知必会-获取视频文件的截图、缩略图
查看>>
(转)理解Bitblt、StretchBlt与SetDIBitsToDevice、StretchDibits
查看>>
ViurtualBox配置虚拟机Linux的网络环境
查看>>
VLC 媒体播放器
查看>>
勿忘国耻2018/09/18
查看>>
Jenkins部署码云SpringBoot项目
查看>>