0
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)
文書を参照して上記のコードを試しましたが、次のエラーが発生しました。方法avoideエラー "TypeError:バイト状のオブジェクトは、 'str'"ではなく、scurで
if "authentication failed" in response.body:
TypeError: a bytes-like object is required, not 'str'
これはresponse.bodyのバイナリファイルのようです。 このエラーを回避する方法はありますか?
私は興味がありますが、ログインが失敗した場合、「認証に失敗しましたか」というレスポンスが表示されますか?
私の質問をお読みいただきありがとうございます。
はあなたの返事をいただき、ありがとうございます。 私は間違いなくそれを解決しました。 –
助けてくれてうれしい!あなたがそれが役に立ったと思ったら、[私の答えを受け入れる](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)を自由に感じてください。 :-) –