title: Scrapy, login with captcha failed
body: <p>I'm using the following spider for crawling the <em>tinyz.us</em> website that requires an authentication.</p>
  
  <pre><code>from scrapy.spiders import BaseSpider
  from scrapy.http import FormRequest
  import urllib2
  
  
  class Start(BaseSpider):
      name = 'test'
      start_urls = ["http://tinyz.us"]
  
      def parse(self, response):
  
          user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
          headers = {'User-Agent': user_agent}
          imgRequest = urllib2.Request("http://tinyz.us/securimage/securimage_show.php", headers=headers)
          imgData = urllib2.urlopen(imgRequest).read()
  
          with open('captcha.png', 'wb') as f:
              f.write(imgData)
  
          captcha = raw_input("-----&gt; Enter the captcha in manually :")
  
          return FormRequest.from_response(
              response=response,
              formdata={"login_user": "myusername",
                        "login_password": "mypass",
                        "captcha_code": captcha},
              formxpath="//*[@id='login-form']",
              callback=self.after_login,
              headers=headers)
  
      def after_login(self, response):
          print("AFTER LOGIN")
          with open('response.html', 'w') as f:
              f.write(response.body)
  </code></pre>
  
  <p>The website uses a constant url for generating the captcha and it seems that each time it generates a new one. I'm not familiar with the respective tech but they way that I tend to get around that problem is saving the captcha and passing it manually.</p>
  
  <p>The problem is that it always returns a failed response, I'm not sure if the problem is because of the way that scrapy passes the data to <code>form</code> or because of the captcha and I can't find a way to debug the spider properly.</p>