简体   繁体   English

美汤4构造函数错误

[英]Beautiful soup 4 constructor error

I am running python 3.5 with BeautifulSoup4 and getting an error when I attempt to pass the plain text of a webpage to the constructor. 我正在使用BeautifulSoup4运行python 3.5,并且在尝试将网页的纯文本传递给构造函数时遇到错误。

The source code I am trying to run is 我正在尝试运行的源代码是

import requests from bs4 
import BeautifulSoup

tcg = 'http://magic.tcgplayer.com/db/deck_search_result.asp?Format=Commander'

sourcecode = requests.get(tcg)

plaintext = sourcecode.text
soup = BeautifulSoup(plaintext)

When running this I get the folloing error 运行此命令时出现以下错误

Traceback (most recent call last):
File "/Users/Brian/PycharmProjects/magic_crawler/main.py", line 11, in <module>
soup = BeautifulSoup(plaintext)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/__init__.py", line 202, in __init__
self._feed()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/__init__.py", line 216, in _feed
self.builder.feed(self.markup)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/builder/_htmlparser.py", line 156, in feed
parser = BeautifulSoupHTMLParser(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'strict'

Python 3.5 is an alpha release (the first beta is expected this weekend but isn't out just yet at the time of this post). Python 3.5是一个Alpha版本 (预计第一个Beta将在本周末发布,但在发布本文时尚未发布)。 BeautifulSoup certainly hasn't claimed any compatibility with 3.5. BeautifulSoup当然没有宣称与3.5兼容。

Stick to using Python 3.4 for now. 现在请继续使用Python 3.4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM