我剛剛買了一本書,告訴我如何刮網站,但第一個例子了蝙蝠的權利是不是爲我工作 - 所以現在我有點不高興,我首先買了這本書,但我想嘗試去實現它。Python的BeautifulSoup錯誤BsObj
在Python 3.5我的代碼:
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.pythonscraping.com/pages/page1.html")
BsObj = BeautifulSoup(html.read())
print(bsObj.h1)*
以下是錯誤我得到
Traceback (most recent call last):
File "C:/Users/MyName/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/bs4/test.py", line 5, in BsObj = BeautifulSoup(html.read())
File "C:\Users\MyName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4__init__.py", line 153, in init builder = builder_class()
File "C:\Users\MyName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\builder_htmlparser.py", line 39, in init return super(HTMLParserTreeBuilder, self).init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'strict'
任何想法將是超級有用嗎? 在此先感謝
謝謝 - 關於錯字,我複製了我的最新文件,我改變了拼寫 - 我做了兩個建議,但仍然出現錯誤。 – PatrickP76
同樣的錯誤? –
是我最初發布的同一個錯誤。我不得不爲這本書下載Python 35,並且之前使用了27版 - 這導致了我無法修復或找到修復程序的問題,因此我卸載了這兩個版本並重新加載了35 - 我的直覺告訴我在安裝35或BS時做了一些錯誤。感謝您的幫助 – PatrickP76