利用爬虫爬取安居客租房数据时遇到这个问题,经查阅解决方式如下: 将soup = BeautifulSoup(r.text, 'lxml')修改成如下形式即可: soup = BeautifulSoup(r.text, 'html.parser')