这就是我的代码,非常简单。由于某种原因,出现上述错误。即使我删除text = str(html)并替换soup = BeautifulSoup(text, 'html.parser')为同样的错误soup = BeautifulSoup(html, 'html.parser')。这是怎么回事?
with urllib.request.urlopen('https://jalopnik.com/search?q=mazda&u=&zo=-07:00') as response:
html = response.read()
text = str(html)
soup = BeautifulSoup(text, 'html.parser')
print(type(soup))
soup = soup.prettify()
print(soup.find_all('div'))
Run Code Online (Sandbox Code Playgroud)