November 2017
Intermediate to advanced
226 pages
5h 59m
English
Here is how we can use Scrapy to crawl websites which require logging in:
def parse(self, response):
return scrapy.FormRequest.from_response(
response,
formdata={'username': 'username', 'password': 'password'},
callback=self.parse_after_login
)
Here, the response object is the HTTP response of the page where we have to fill in the login form. The FormRequest method includes the credentials that we need to log in and the callback method that is used to parse the page after login.
Read now
Unlock full access