把寫內容過程中經常用的內容段備份一下,下面的內容內容是關於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)
