From 613406e4f6bc95f7306b18e54ba47ea718b63fd8 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Mon, 1 Feb 2021 20:42:58 -0800 Subject: [PATCH] fix: check for existence of input field in form --- teslajsonpy/connection.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/teslajsonpy/connection.py b/teslajsonpy/connection.py index 539a09fa..837b69ae 100644 --- a/teslajsonpy/connection.py +++ b/teslajsonpy/connection.py @@ -436,13 +436,14 @@ def get_inputs(soup: BeautifulSoup, searchfield=None) -> Dict[str, str]: form = soup.find("form", searchfield) if not form: form = soup.find("form") - for field in form.find_all("input"): - try: - data[field["name"]] = "" - if field["type"] and field["type"] == "hidden": - data[field["name"]] = field["value"] - except BaseException: # pylint: disable=broad-except - pass + if form.find_all("input"): + for field in form.find_all("input"): + try: + data[field["name"]] = "" + if field["type"] and field["type"] == "hidden": + data[field["name"]] = field["value"] + except BaseException: # pylint: disable=broad-except + pass return data