From 0728dd8c6d6967bf54d230ea833ae2895a8ad56b Mon Sep 17 00:00:00 2001 From: RicterZ Date: Thu, 11 Apr 2019 22:41:37 +0800 Subject: [PATCH] use text rather than content --- nhentai/parser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nhentai/parser.py b/nhentai/parser.py index bb196fe..b405998 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -37,7 +37,7 @@ def _get_csrf_token(content): def login(username, password): - csrf_token = _get_csrf_token(request('get', url=constant.LOGIN_URL).content) + csrf_token = _get_csrf_token(request('get', url=constant.LOGIN_URL).text) if os.getenv('DEBUG'): logger.info('Getting CSRF token ...') @@ -51,15 +51,15 @@ def login(username, password): } resp = request('post', url=constant.LOGIN_URL, data=login_dict) - if 'You\'re loading pages way too quickly.' in resp.content: - csrf_token = _get_csrf_token(resp.content) + if 'You\'re loading pages way too quickly.' in resp.text: + csrf_token = _get_csrf_token(resp.text) resp = request('post', url=resp.url, data={'csrfmiddlewaretoken': csrf_token, 'next': '/'}) - if 'Invalid username/email or password' in resp.content: + if 'Invalid username/email or password' in resp.text: logger.error('Login failed, please check your username and password') exit(1) - if 'You\'re loading pages way too quickly.' in resp.content: + if 'You\'re loading pages way too quickly.' in resp.text: logger.error('You meet challenge again, please submit a issue at https://github.com/RicterZ/nhentai/issues') exit(2)