把寫內容過程當中常常用的內容段備份一下,下面的內容內容是關於scrapy抓取某些網站出現AttributeError: 'Response' object has no attribute 'body_as_unicode'的解決辦法的內容,應該是對碼農們也有用。scrapy
def parse(self, response):
hxs=Selector(response)網站
for url in detail_url_list:
if 'goods' in url:
yield Request(url, callback=self.parse_detail)url
寫成下面這個樣子便可
code
def parse(self, response):
hxs=Selector(text=response.body)unicode
for url in detail_url_list:
if 'goods' in url:
yield Request(url, callback=self.parse_detail)object
注意這句話:hxs=Selector(text=response.body)
yield