Issue: when I try to execute the script, BeautifulSoup(html, ...)
gives the error message "TypeError: object of type 'Response' has no len(). I tried passing the actual html as a parameter, but it still doesn't work.
import requests
url = 'http://vineoftheday.com/?order_by=rating'
response = requests.get(url)
html = response.content
soup = BeautifulSoup(html, "html.parser")
Try to pass the HTML text directly
You are getting
response.content
. But it return response body as bytes (docs). But you should passstr
to BeautifulSoup constructor (docs). So you need to use theresponse.text
instead of getting content.you are getting only response code in 'response' and always use browser header for security otherwise you will face many issues
Find header in debugger console network section 'header' UserAgent
Try
If you're using
requests.get('https://example.com')
to get the HTML, you should userequests.get('https://example.com').text
.