[Tutor] html2text expects bytes-like object
Julius Hamilton
juliushamilton100 at gmail.com
Mon Nov 8 08:33:28 EST 2021
Hey,
I would like to convert a webpage to plaintext with html2text.
I tried:
import requests
import html2text
r = requests.get("https://www.google.com")
html = r.content
html2text.html2text(html)
But this returns:
TypeError: a bytes-like object is required, not 'str'
In the documentation, it shows the above html2text method working for what
appears to be a string.
Why am I getting the response that I need to pass it a "bytes-like object"?
Thanks very much,
Julius
More information about the Tutor
mailing list