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