我正在尝试使用python,并尝试将网页数据复制到文本文件中,并在其中出现以下python错误
import html2text
url=''
page = urllib.request.urlopen(url)
html_content = page.read()
rendered_content = html2text.html2text(html_content)
请参阅以下错误。
rendered_content = html2text.html2text(html_content)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python36\lib\site-packages\html2text\__init__.py", line 937, in html2text
return h.handle(html)
File "C:\Program Files\Python36\lib\site-packages\html2text\__init__.py", line 149, in handle
self.feed(data)
File "C:\Program Files\Python36\lib\site-packages\html2text\__init__.py", line 145, in feed
data = data.replace("</' + 'script>", "</ignore>")
TypeError: a bytes-like object is required, not 'str'
rendered_content = html2text.html2text(html_content)
File "<stdin>", line 1
rendered_content = html2text.html2text(html_content)
^