name = 'example.com'
start_urls = ['http://www.example.com/users/login.php']

def parse(self, response):
    return [FormRequest.from_response(response, formdata={'username':
        'john', 'password': 'secret'}, callback=self.after_login)]

def after_login(self, response):
    if 'authentication failed' in response.body:
        self.log('Login failed', level=log.ERROR)
return
How to download file from website that requires login information using Python?