From 1331bc0d3b9067bc2692e29934e96d4fd49e78b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andy=20Teijelo=20P=C3=A9rez?= Date: Wed, 11 Oct 2017 09:27:52 -0400 Subject: [PATCH] Fix "nauta cards" if some credentials are wrong --- nauta.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nauta.py b/nauta.py index 5343e6a..f9fa5ca 100755 --- a/nauta.py +++ b/nauta.py @@ -241,9 +241,10 @@ def fetch_expire_date(username, password): form['password'] = password r = session.post(action, form) soup = bs4.BeautifulSoup(r.text, 'html.parser') - exp_text = soup.find(string=re.compile("expiración"))\ - .parent.find_next_sibling('td')\ - .text.strip() + exp_node = soup.find(string=re.compile("expiración")) + if not exp_node: + return "**invalid credentials**" + exp_text = exp_node.parent.find_next_sibling('td').text.strip() exp_text = exp_text.replace('\\', '') return exp_text