scrapy抓取某些网站出现AttributeError_ object has no attribute 的解决办法的代码.txt

把写内容过程中经常用的内容段备份一下,下面的内容内容是关于scrapy抓取某些网站出现AttributeError: 'Response' object has no attribute 'body_as_unicode'的解决办法的内容,应该是对码农们也有用。

def parse(self, response):
hxs=Selector(response)

for url in detail_url_list:
if 'goods' in url:
yield Request(url, callback=self.parse_detail)





写成下面这个样子即可



def parse(self, response):
hxs=Selector(text=response.body)

for url in detail_url_list:
if 'goods' in url:
yield Request(url, callback=self.parse_detail)





注意这句话:hxs=Selector(text=response.body)





猜你喜欢

转载自www.cnblogs.com/gladiolus/p/11257632.html