import urllib
import urllib.request
from bs4 import BeautifulSoup
theurl = "https://twitter.com/official_YDP09"
thepage = urllib.request.urlopen(theurl)
soup = BeautifulSoup(thepage, "html.parser")
print(Soup.title)
,其結果是錯誤BeautifulSoup錯誤
C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py"
Traceback (most recent call last):
File "C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py", line 7, in <module>
soup = BeautifulSoup(thepage, "html.parser")
File "C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bs4\__init__.py", line 153, in __init__
builder = builder_class()
File "C:\Users\Yohan\AppData\Local\Programs\Python\Python36-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'
Process finished with exit code 1
我有嘗試,其結果是: 回溯(最近最後一次通話): 文件「test.py」,3號線,在 從BS4進口BeautifulSoup ModuleNotFoundError:否模塊命名爲'bs4' –
檢查我的答案@YohanesDwiPratama,因爲你使用python 3你需要再次安裝bs4 –