BeautifulSoup模块学习

来源:互联网 发布:管理类联考网络冲刺班 编辑:程序博客网 时间:2024/06/03 15:21

转载博客地址:http://cuiqingcai.com/1319.html

创建 Beautiful Soup 对象

from bs4 import BeautifulSoup

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

html = """<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 href="http://example.com/elsie" class="sister" id="link1"><!-- Elsie --></a>,<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;and they lived at the bottom of a well.</p><p class="story">...</p>"""

创建 beautifulsoup 对象

soup = BeautifulSoup(html,'lxml')










0 0