我正在尝试在Pycharm中运行以下代码,并且得到"Process finished with exit code 0"
,我猜测这意味着程序正在运行,但没有任何输出。我已经确保正确安装了beautifulsoup
,requests
和lxml
。我不确定还有什么可能是错误的,主要是因为我从Corey schafer的视频中复制了它,并且对他来说还不错。
from bs4 import BeautifulSoup
import requests
source = requests.get('https://coreyms.com/').text
soup = BeautifulSoup(source, 'lxml')
print(soup.prettify())
答案 0 :(得分:0)
安装html5lib
。
通过使用pip install html5lib
下载后,尝试以下代码:
soup = BeautifulSoup(source, 'html.parser')
答案 1 :(得分:0)
尝试使用此代码!
import requests
from bs4 import BeautifulSoup
page = requests.get('https://coreyms.com/')
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.prettify())