Skip to content

Commit

Permalink
Merge pull request scrapy#3615 from Gallaecio/form-request-example
Browse files Browse the repository at this point in the history
Indicate that users must implement their own authentication result check
  • Loading branch information
eLRuLL authored Feb 7, 2019
2 parents 65d6313 + 38af090 commit b364bfb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/topics/request-response.rst
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ method for this job. Here's an example spider which uses it::

import scrapy

def authentication_failed(response):
# TODO: Check the contents of the response and return True if it failed
# or False if it succeeded.
pass

class LoginSpider(scrapy.Spider):
name = 'example.com'
start_urls = ['http://www.example.com/users/login.php']
Expand All @@ -501,8 +506,7 @@ method for this job. Here's an example spider which uses it::
)

def after_login(self, response):
# check login succeed before going on
if "authentication failed" in response.body:
if authentication_failed(response):
self.logger.error("Login failed")
return

Expand Down

0 comments on commit b364bfb

Please sign in to comment.