TypeError: object of type 'Response' has no len()

源代码:

url = 'https://www.imooc.com/course/list?c=python'
wb_data = requests.get(url)
Soup = BeautifulSoup(wb_data, 'lxml', from_encoding='utf-8')

出现错误的原因是因为这里的wb_data是requests对象,无法用BeautifulSoup解析,可以在wb_data后面加上content

Soup = BeautifulSoup(wb_data.content, 'lxml', from_encoding='utf-8')即可

猜你喜欢

转载自blog.csdn.net/m0_37827405/article/details/81163399