|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#!user\bin\env python
#-*-conding:UTF-8 -*-
# author zlz time: 2018.07.16
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>
"""
soup = BeautifulSoup(html)
print(soup.prettify())
执行后出现如下:
D:\phython-64bit\python.exe D:/2/14.py
Traceback (most recent call last):
File "D:/2/14.py", line 17, in <module>
soup = BeautifulSoup(html)
File "D:\phython-64bit\lib\bs4\__init__.py", line 168, in __init__
self._feed()
File "D:\phython-64bit\lib\bs4\__init__.py", line 181, in _feed
self.builder.feed(self.markup)
File "D:\phython-64bit\lib\bs4\builder\_htmlparser.py", line 131, in feed
parser = BeautifulSoupHTMLParser(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'strict'
Process finished with exit code 1 |
|