start_urls = ['https://github.com/login']
def parse(self, response):
return scrapy.FormRequest.from_response(response,formdata={'login': 'xx',
'password': 'xx'},callback=self.after_login)
def after_login(self, response):
if "authentication failed" in response.body:
self.logger.info("fail xx %s", response.body)
I tried the above code with reference to the document, but the following error occurred.
if "authentication failed" in response.body:
TypeError: a bytes-like object is required, not 'str'
It looks like binary file in response.body. Is there a way to avoid this error?
and I'm Curious that generally, if login fails, whether "authentication failed" is displayed in response.body?
Thank you for reading my question.