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 –