Fix "nauta cards" if some credentials are wrong

This commit is contained in:
Andy Teijelo Pérez 2017-10-11 09:27:52 -04:00
parent 26a7239020
commit 1331bc0d3b

View file

@ -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