Python中Beautiful Soup库详细教程

1. Beautiful Soup的简介

简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据。官方解释如下:

    Beautiful Soup提供一些简单的、python式的函数用来处理导航、搜索、修改分析树等功能。它是一个工具箱,通过解析文档为用户提供需要抓取的数据,因为简单,所以不需要多少代码就可以写出一个完整的应用程序。

    Beautiful Soup自动将输入文档转换为Unicode编码,输出文档转换为utf-8编码。你不需要考虑编码方式,除非文档没有指定一个编码方式,这时,Beautiful Soup就不能自动识别编码方式了。然后,你仅仅需要说明一下原始编码方式就可以了。

    Beautiful Soup已成为和lxml、html6lib一样出色的python解释器,为用户灵活地提供不同的解析策略或强劲的速度。

废话不多说,我们来试一下吧~
2. Beautiful Soup 安装

Beautiful Soup 3 目前已经停止开发,推荐在现在的项目中使用Beautiful Soup 4,不过它已经被移植到BS4了,也就是说导入时我们需要 import bs4 。所以这里我们用的版本是 Beautiful Soup 4.3.2 (简称BS4),另外据说 BS4 对 Python3 的支持不够好,不过我用的是 Python2.7.7,如果有小伙伴用的是 Python3 版本,可以考虑下载 BS3 版本。

如果你用的是新版的Debain或Ubuntu,那么可以通过系统的软件包管理来安装,不过它不是最新版本,目前是4.2.1版本
 

?
1
sudo apt-get install Python-bs4

如果想安装最新的版本,请直接下载安装包来手动安装,也是十分方便的方法。在这里我安装的是 Beautiful Soup 4.3.2

?
1
Beautiful Soup 3.2.1Beautiful Soup 4.3.2

下载完成之后解压

运行下面的命令即可完成安装
 

?
1
sudo python setup.py install

如下图所示,证明安装成功了


然后需要安装 lxml
 

?
1
sudo apt-get install Python-lxml

Beautiful Soup支持Python标准库中的HTML解析器,还支持一些第三方的解析器,如果我们不安装它,则 Python 会使用 Python默认的解析器,lxml 解析器更加强大,速度更快,推荐安装。
3. 开启Beautiful Soup 之旅

在这里先分享官方文档链接,不过内容是有些多,也不够条理,在此本文章做一下整理方便大家参考。

官方文档
4. 创建 Beautiful Soup 对象

首先必须要导入 bs4 库
 

?
1
from bs4 import BeautifulSoup

我们创建一个字符串,后面的例子我们便会用它来演示
 

?
1
2
3
4
5
6
7
8
9
10
11
html = """
The Dormouse's story

The Dormouse's story

Once upon a time there were three little sisters; and their names were

,
Lacie and
and they lived at the bottom of a well.

...

"""

创建 beautifulsoup 对象
 

?
1
soup = BeautifulSoup(html)

另外,我们还可以用本地 HTML 文件来创建对象,例如
 

?
1
soup = BeautifulSoup( open ( 'index.html' ))

上面这句代码便是将本地 index.html 文件打开,用它来创建 soup 对象

下面我们来打印一下 soup 对象的内容,格式化输出
 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
print soup.prettify()
  
 
  </code> </div> <div class="line number6 index5 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">The Dormouse's story</code> </div> <div class="line number7 index6 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">title></code> </div> <div class="line number8 index7 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">head></code> </div> <div class="line number9 index8 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><body></code> </div> <div class="line number10 index9 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><p </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"title"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> name</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"dromouse"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number11 index10 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><b></code> </div> <div class="line number12 index11 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">The Dormouse's story</code> </div> <div class="line number13 index12 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">b></code> </div> <div class="line number14 index13 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">p></code> </div> <div class="line number15 index14 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><p </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"story"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number16 index15 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">Once upon a time there were three little sisters; </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">and</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> their names were</code> </div> <div class="line number17 index16 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><a </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"sister"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> href</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"http://example.com/elsie"</code> <code class="py functions" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:rgb(255,20,147)!important; background:none!important"> id</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"link1"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number18 index17 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><!</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">-</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">-</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> Elsie </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">-</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">-</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number19 index18 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">a></code> </div> <div class="line number20 index19 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">,</code> </div> <div class="line number21 index20 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><a </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"sister"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> href</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"http://example.com/lacie"</code> <code class="py functions" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:rgb(255,20,147)!important; background:none!important"> id</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"link2"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number22 index21 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">Lacie</code> </div> <div class="line number23 index22 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">a></code> </div> <div class="line number24 index23 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">and</code> </div> <div class="line number25 index24 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><a </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"sister"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> href</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"http://example.com/tillie"</code> <code class="py functions" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:rgb(255,20,147)!important; background:none!important"> id</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"link3"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number26 index25 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">Tillie</code> </div> <div class="line number27 index26 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">a></code> </div> <div class="line number28 index27 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">;</code> </div> <div class="line number29 index28 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">and</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> they lived at the bottom of a well.</code> </div> <div class="line number30 index29 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">p></code> </div> <div class="line number31 index30 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><p </code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">class</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">=</code> <code class="py string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"story"</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number32 index31 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">  </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">...</code> </div> <div class="line number33 index32 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">p></code> </div> <div class="line number34 index33 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">body></code> </div> <div class="line number35 index34 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="py keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">/</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">html></code> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> 以上便是输出结果,格式化打印出了它的内容,这个函数经常用到,小伙伴们要记好咯。<br> <strong>5. 四大对象种类</strong></p> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> Beautiful Soup将复杂HTML文档转换成一个复杂的树形结构,每个节点都是Python对象,所有对象可以归纳为4种:</p> <ol style="margin:0px; padding:0px; list-style:none; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; font-size:14px; line-height:25.2000007629395px"> <li style="margin:0px; padding:0px 0px 0px 10px; list-style:none; line-height:20px; color:rgb(76,76,76)">     Tag</li> <li style="margin:0px; padding:0px 0px 0px 10px; list-style:none; line-height:20px; color:rgb(76,76,76)">     NavigableString</li> <li style="margin:0px; padding:0px 0px 0px 10px; list-style:none; line-height:20px; color:rgb(76,76,76)">     BeautifulSoup</li> <li style="margin:0px; padding:0px 0px 0px 10px; list-style:none; line-height:20px; color:rgb(76,76,76)">     Comment</li> </ol> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> 下面我们进行一一介绍<br> <strong>(1)Tag</strong></p> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> Tag 是什么?通俗点讲就是 HTML 中的一个个标签,例如<br>  <br> </p> <div class="jb51code" style="line-height:25.2000007629395px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif"> <div style="line-height:25.2000007629395px"> <div id="highlighter_588111" class="syntaxhighlighter xhtml" style="width:653px; line-height:25.2000007629395px; margin:1em 0px!important; position:relative!important; overflow:auto!important"> <div class="toolbar" style="line-height:13.1999998092651px; border:none!important; bottom:auto!important; float:none!important; height:11px!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:absolute!important; right:1px!important; top:1px!important; vertical-align:baseline!important; width:11px!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; z-index:10!important; color:white!important; background:rgb(108,226,108)!important"> <span style="line-height:25.2000007629395px">?</span> </div> <table border="0" style="border-collapse:collapse; border-spacing:0px; width:653px; clear:both; padding:0px!important; margin:0px!important; font-size:1em!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; background:none!important"> <tbody style="border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> <tr style="border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> <td class="gutter" style="padding:8px; font-size:14px; line-height:15.3999996185303px; margin:0px!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; color:rgb(175,175,175)!important; background:none!important"> <div class="line number1 index0 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 1 </div> <div class="line number2 index1 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 2 </div> <div class="line number3 index2 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 3 </div> </td> <td class="code" style="padding:8px; font-size:14px; line-height:15.3999996185303px; width:621px; margin:0px!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; background:none!important"> <div class="container" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:relative!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; background:none!important"> <div class="line number1 index0 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="xhtml keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">title</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">>The Dormouse's story</</code> <code class="xhtml keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">title</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> <div class="line number2 index1 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="xhtml spaces" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> </code>  </div> <div class="line number3 index2 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"><</code> <code class="xhtml keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">a</code> <code class="xhtml color1" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:gray!important; background:none!important"> class</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">=</code> <code class="xhtml string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"sister"</code> <code class="xhtml color1" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:gray!important; background:none!important"> href</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">=</code> <code class="xhtml string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"http://example.com/elsie"</code> <code class="xhtml color1" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:gray!important; background:none!important"> id</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">=</code> <code class="xhtml string" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:blue!important; background:none!important">"link1"</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">>Elsie</</code> <code class="xhtml keyword" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-weight:bold!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,102,153)!important; background:none!important">a</code> <code class="xhtml plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important">></code> </div> </div> </td> </tr> </tbody> </table> </div> </div> </div> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> 上面的 title a 等等 HTML 标签加上里面包括的内容就是 Tag,下面我们来感受一下怎样用 Beautiful Soup 来方便地获取 Tags</p> <p style="margin-top:0px; margin-bottom:0px; padding-top:5px; padding-bottom:5px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif; line-height:25.2000007629395px"> 下面每一段代码中注释部分即为运行结果<br>  <br> </p> <div class="jb51code" style="line-height:25.2000007629395px; font-size:14px; font-family:Tahoma,Helvetica,Arial,宋体,sans-serif"> <div style="line-height:25.2000007629395px"> <div id="highlighter_450660" class="syntaxhighlighter py" style="width:653px; line-height:25.2000007629395px; margin:1em 0px!important; position:relative!important; overflow:auto!important"> <div class="toolbar" style="line-height:13.1999998092651px; border:none!important; bottom:auto!important; float:none!important; height:11px!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:absolute!important; right:1px!important; top:1px!important; vertical-align:baseline!important; width:11px!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; z-index:10!important; color:white!important; background:rgb(108,226,108)!important"> <span style="line-height:25.2000007629395px">?</span> </div> <table border="0" style="border-collapse:collapse; border-spacing:0px; width:708px; clear:both; padding:0px!important; margin:0px!important; font-size:1em!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; background:none!important"> <tbody style="border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> <tr style="border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> <td class="gutter" style="padding:8px; font-size:14px; line-height:15.3999996185303px; margin:0px!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; color:rgb(175,175,175)!important; background:none!important"> <div class="line number1 index0 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 1 </div> <div class="line number2 index1 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 2 </div> <div class="line number3 index2 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 3 </div> <div class="line number4 index3 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 4 </div> <div class="line number5 index4 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 5 </div> <div class="line number6 index5 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 6 </div> <div class="line number7 index6 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 7 </div> <div class="line number8 index7 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 8 </div> <div class="line number9 index8 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 9 </div> <div class="line number10 index9 alt1" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 10 </div> <div class="line number11 index10 alt2" style="line-height:15.3999996185303px; border-width:0px 3px 0px 0px!important; border-right-style:solid!important; border-right-color:rgb(108,226,108)!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 0.5em 0px 1em!important; position:static!important; right:auto!important; text-align:right!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> 11 </div> </td> <td class="code" style="padding:8px; font-size:14px; line-height:15.3999996185303px; width:668px; margin:0px!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; min-height:inherit!important; background:none!important"> <div class="container" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:relative!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; background:none!important"> <div class="line number1 index0 alt2" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py functions" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:rgb(255,20,147)!important; background:none!important">print</code> <code class="py plain" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; background:none!important"> soup.title</code> </div> <div class="line number2 index1 alt1" style="line-height:15.3999996185303px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px 1em!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:inherit!important; white-space:pre!important"> <code class="py comments" style="font-family:Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important; color:rgb(0,130,0)!important; background:none!important">#<title>The Dormouse's story
  
print soup.head
#The Dormouse's story
  
print soup.a
#
  
print soup.p
#

The Dormouse's story

我们可以利用 soup加标签名轻松地获取这些标签的内容,是不是感觉比正则表达式方便多了?不过有一点是,它查找的是在所有内容中的第一个符合要求的标签,如果要查询所有的标签,我们在后面进行介绍。

我们可以验证一下这些对象的类型
 

?
1
2
print type (soup.a)
#

对于 Tag,它有两个重要的属性,是 name 和 attrs,下面我们分别来感受一下

?
1
2
3
4
5
6
name
  
print soup.name
print soup.head.name
#[document]
#head

soup 对象本身比较特殊,它的 name 即为 [document],对于其他内部标签,输出的值便为标签本身的名称。

?
1
2
3
4
attrs
  
print soup.p.attrs
#{'class': ['title'], 'name': 'dromouse'}

在这里,我们把 p 标签的所有属性打印输出了出来,得到的类型是一个字典。

如果我们想要单独获取某个属性,可以这样,例如我们获取它的 class 叫什么
 

?
1
2
print soup.p[ 'class' ]
#['title']

还可以这样,利用get方法,传入属性的名称,二者是等价的
 

?
1
2
print soup.p.get( 'class' )
#['title']

我们可以对这些属性和内容等等进行修改,例如
 

?
1
2
3
soup.p[ 'class' ] = "newClass"
print soup.p
#

The Dormouse's story

还可以对这个属性进行删除,例如
 

?
1
2
3
del soup.p[ 'class' ]
print soup.p
#

The Dormouse's story

不过,对于修改删除的操作,不是我们的主要用途,在此不做详细介绍了,如果有需要,请查看前面提供的官方文档
(2)NavigableString

既然我们已经得到了标签的内容,那么问题来了,我们要想获取标签内部的文字怎么办呢?很简单,用 .string 即可,例如
 

?
1
2
print soup.p.string
#The Dormouse's story

这样我们就轻松获取到了标签里面的内容,想想如果用正则表达式要多麻烦。它的类型是一个 NavigableString,翻译过来叫 可以遍历的字符串,不过我们最好还是称它英文名字吧。
 

?
1
2
print type (soup.p.string)
#

来检查一下它的类型
 

?
1
2
print type (soup.p.string)
#

(3)BeautifulSoup

BeautifulSoup 对象表示的是一个文档的全部内容.大部分时候,可以把它当作 Tag 对象,是一个特殊的 Tag,我们可以分别获取它的类型,名称,以及属性来感受一下
 

?
1
2
3
4
5
6
print type (soup.name)
#
print soup.name
# [document]
print soup.attrs
#{} 空字典

(4)Comment

Comment 对象是一个特殊类型的 NavigableString 对象,其实输出的内容仍然不包括注释符号,但是如果不好好处理它,可能会对我们的文本处理造成意想不到的麻烦。

我们找一个带注释的标签
 

?
1
2
3
print soup.a
print soup.a.string
print type (soup.a.string)

运行结果如下
 

a 标签里的内容实际上是注释,但是如果我们利用 .string 来输出它的内容,我们发现它已经把注释符号去掉了,所以这可能会给我们带来不必要的麻烦。

另外我们打印输出下它的类型,发现它是一个 Comment 类型,所以,我们在使用前最好做一下判断,判断代码如下
 

?
1
2
if type (soup.a.string) = = bs4.element.Comment:
   print soup.a.string

上面的代码中,我们首先判断了它的类型,是否为 Comment 类型,然后再进行其他操作,如打印输出。
6. 遍历文档树
(1)直接子节点

    要点:.contents .children 属性

.contents

tag 的 .content 属性可以将tag的子节点以列表的方式输出
 

?
1
2
print soup.head.contents
#[The Dormouse's story]

输出方式为列表,我们可以用列表索引来获取它的某一个元素
 

?
1
2
3
4
print soup.head.contents[ 0 ]
#The Dormouse's story
 
.children

它返回的不是一个 list,不过我们可以通过遍历获取所有子节点。

我们打印输出 .children 看一下,可以发现它是一个 list 生成器对象
 

?
1
2
print soup.head.children
#

我们怎样获得里面的内容呢?很简单,遍历一下就好了,代码及结果如下
 

?
1
2
3
4
5
6
7
8
9
10
11
12

(2)所有子孙节点

    知识点:.descendants 属性

.descendants

.contents 和 .children 属性仅包含tag的直接子节点,.descendants 属性可以对所有tag的子孙节点进行递归循环,和 children类似,我们也需要遍历获取其中的内容。
 

?
1
2
for child in soup.descendants:
   print child

运行结果如下,可以发现,所有的节点都被打印出来了,先生最外层的 HTML标签,其次从 head 标签一个个剥离,以此类推。
 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
< html >< head >< title >The Dormouse's story title > head >
< body >
< p class = "title" name = "dromouse" >< b >The Dormouse's story b > p >
< p class = "story" >Once upon a time there were three little sisters; and their names were
< a class = "sister" href = "http://example.com/elsie" id = "link1" > a >,
< a class = "sister" href = "http://example.com/lacie" id = "link2" >Lacie a > and
< a class = "sister" href = "http://example.com/tillie" id = "link3" >Tillie a >;
and they lived at the bottom of a well. p >
< p class = "story" >... p >
body > html >
< head >< title >The Dormouse's story title > head >
< title >The Dormouse's story title >
The Dormouse's story
  
< body >
< p class = "title" name = "dromouse" >< b >The Dormouse's story b > p >
< p class = "story" >Once upon a time there were three little sisters; and their names were
< a class = "sister" href = "http://example.com/elsie" id = "link1" > a >,
< a class = "sister" href = "http://example.com/lacie" id = "link2" >Lacie a > and
< a class = "sister" href = "http://example.com/tillie" id = "link3" >Tillie a >;
and they lived at the bottom of a well. p >
< p class = "story" >... p >
body >
  
< p class = "title" name = "dromouse" >< b >The Dormouse's story b > p >
< b >The Dormouse's story b >
The Dormouse's story
  
< p class = "story" >Once upon a time there were three little sisters; and their names were
< a class = "sister" href = "http://example.com/elsie" id = "link1" > a >,
< a class = "sister" href = "http://example.com/lacie" id = "link2" >Lacie a > and
< a class = "sister" href = "http://example.com/tillie" id = "link3" >Tillie a >;
and they lived at the bottom of a well. p >
Once upon a time there were three little sisters; and their names were
  
< a class = "sister" href = "http://example.com/elsie" id = "link1" > a >
  Elsie
,
  
< a class = "sister" href = "http://example.com/lacie" id = "link2" >Lacie a >
Lacie
  and
  
< a class = "sister" href = "http://example.com/tillie" id = "link3" >Tillie a >
Tillie
;
and they lived at the bottom of a well.
  
< p class = "story" >... p >
...

(3)节点内容

    知识点:.string 属性

如果tag只有一个 NavigableString 类型子节点,那么这个tag可以使用 .string 得到子节点。如果一个tag仅有一个子节点,那么这个tag也可以使用 .string 方法,输出结果与当前唯一子节点的 .string 结果相同。

通俗点说就是:如果一个标签里面没有标签了,那么 .string 就会返回标签里面的内容。如果标签里面只有唯一的一个标签了,那么 .string 也会返回最里面的内容。例如
 

?
1
2
3
4
print soup.head.string
#The Dormouse's story
print soup.title.string
#The Dormouse's story

如果tag包含了多个子节点,tag就无法确定,string 方法应该调用哪个子节点的内容, .string 的输出结果是 None
 

?
1
2
print soup.html.string
# None

(4)多个内容

    知识点: .strings .stripped_strings 属性

.strings

获取多个内容,不过需要遍历获取,比如下面的例子
 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
for string in soup.strings:
   print ( repr (string))
   # u"The Dormouse's story"
   # u'\n\n'
   # u"The Dormouse's story"
   # u'\n\n'
   # u'Once upon a time there were three little sisters; and their names were\n'
   # u'Elsie'
   # u',\n'
   # u'Lacie'
   # u' and\n'
   # u'Tillie'
   # u';\nand they lived at the bottom of a well.'
   # u'\n\n'
   # u'...'
   # u'\n'

.stripped_strings

输出的字符串中可能包含了很多空格或空行,使用 .stripped_strings 可以去除多余空白内容
 

?
1
2
3
4
5
6
7
8
9
10
11
12
for string in soup.stripped_strings:
   print ( repr (string))
   # u"The Dormouse's story"
   # u"The Dormouse's story"
   # u'Once upon a time there were three little sisters; and their names were'
   # u'Elsie'
   # u','
   # u'Lacie'
   # u'and'
   # u'Tillie'
   # u';\nand they lived at the bottom of a well.'
   # u'...'

(5)父节点

    知识点: .parent 属性

 

?

你可能感兴趣的:(Python中Beautiful Soup库详细教程)