From 32133051da38c91d82f671c3f47f034a2c393971 Mon Sep 17 00:00:00 2001 From: legendjslc <164022321@qq.com> Date: Mon, 31 Oct 2022 17:50:08 +0800 Subject: [PATCH] Update earthexplorer.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit delete ‘ncform ’ in get_token, because the login page dose not use it. --- landsatxplore/earthexplorer.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/landsatxplore/earthexplorer.py b/landsatxplore/earthexplorer.py index 9b39dbb..acbba54 100644 --- a/landsatxplore/earthexplorer.py +++ b/landsatxplore/earthexplorer.py @@ -36,14 +36,11 @@ def _get_tokens(body): """Get `csrf_token` and `__ncforminfo`.""" csrf = re.findall(r'name="csrf" value="(.+?)"', body)[0] - ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0] if not csrf: raise EarthExplorerError("EE: login failed (csrf token not found).") - if not ncform: - raise EarthExplorerError("EE: login failed (ncforminfo not found).") - return csrf, ncform + return csrf class EarthExplorer(object): @@ -63,12 +60,11 @@ def logged_in(self): def login(self, username, password): """Login to Earth Explorer.""" rsp = self.session.get(EE_LOGIN_URL) - csrf, ncform = _get_tokens(rsp.text) + csrf= _get_tokens(rsp.text) payload = { "username": username, "password": password, - "csrf": csrf, - "__ncforminfo": ncform, + "csrf": csrf } rsp = self.session.post(EE_LOGIN_URL, data=payload, allow_redirects=True)