python scrapy';str';对象没有属性';编码';

python scrapy';str';对象没有属性';编码';,python,python-2.7,scrapy,Python,Python 2.7,Scrapy,这是我的蜘蛛 class AjaxSpider(BaseSpider): name = "AjaxSpider" start_urls = ['http://localhost:7908/Test.html']; def parse(self, response): open('firstResponse', 'wb').write(response.body) return [FormRequest.from_response('htt

这是我的蜘蛛

class AjaxSpider(BaseSpider):
    name = "AjaxSpider"
    start_urls = ['http://localhost:7908/Test.html'];

    def parse(self, response):
        open('firstResponse', 'wb').write(response.body)
        return [FormRequest.from_response('http://localhost:7908/ToLoadAjax.aspx', callback=self.parseAjax)]

    def parseAjax(self,response):
      open('AjaxResponse', 'wb').write(response.body)
我得到了一个例外:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\twisted\internet\base.py", line 1201, in mainLoop
    self.runUntilCurrent()
  File "C:\Python27\lib\site-packages\twisted\internet\base.py", line 824, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 382, in callback
    self._startRunCallbacks(result)
  File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 490, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "C:\Python27\lib\site-packages\twisted\internet\defer.py", line 577, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "testAjax\spiders\Spider.py", line 13, in parse
    return [FormRequest.from_response('http://localhost:7908/ToLoadAjax.aspx', callback=self.parseAjax)]
  File "C:\Python27\lib\site-packages\scrapy-0.20.2-py2.7.egg\scrapy\http\request\form.py", line 35, in from_response
    kwargs.setdefault('encoding', response.encoding)
exceptions.AttributeError: 'str' object has no attribute 'encoding'
回溯(最近一次呼叫最后一次):
文件“C:\Python27\lib\site packages\twisted\internet\base.py”,第1201行,在mainLoop中
self.rununtlcurrent()
文件“C:\Python27\lib\site packages\twisted\internet\base.py”,第824行,在rununtlcurrent中
call.func(*call.args,**call.kw)
回调中的文件“C:\Python27\lib\site packages\twisted\internet\defer.py”,第382行
自启动返回(结果)
文件“C:\Python27\lib\site packages\twisted\internet\defer.py”,第490行,在startRunCallbacks中
self.\u runCallbacks()
---  ---
文件“C:\Python27\lib\site packages\twisted\internet\defer.py”,第577行,在运行回调中
current.result=回调(current.result,*args,**kw)
文件“testAjax\Spider\Spider.py”,第13行,在解析中
return[FormRequest.from_response('http://localhost:7908/ToLoadAjax.aspx,callback=self.parseAjax)]
文件“C:\Python27\lib\site packages\scrapy-0.20.2-py2.7.egg\scrapy\http\request\form.py”,第35行,from\u响应
kwargs.setdefault('encoding',response.encoding)
exceptions.AttributeError:“str”对象没有“encoding”属性
我正在尝试使用fromrequest获取post呼叫


我可以在我的chrome webkit xhr中看到post调用。

它看起来像是从\u response需要一个response对象。不是URL字符串


那么,如果使用
返回[FormRequest.from\u response(response,callback=self.parseAjax)]
会发生什么呢?