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)






免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM