Skip to content

Commit

Permalink
Updated: get account number (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Reg authored May 3, 2023
1 parent 700aba8 commit c31a881
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions evergy/evergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, username, password):
self.login_url = "https://www.evergy.com/log-in"
self.logout_url = "https://www.evergy.com/logout"
self.account_summary_url = (
"https://www.evergy.com/ma/my-account/account-summary"
"https://www.evergy.com/sc-api/account/getaccountpremiseselector?isWidgetPage=false&hasNoSelector=false"
)
self.account_dashboard_url = (
"https://www.evergy.com/api/account/{accountNum}/dashboard/current"
Expand All @@ -55,14 +55,11 @@ def login(self):
)
logging.debug("Login response: " + str(r.status_code))
r = self.session.get(self.account_summary_url)
soup = BeautifulSoup(r.text, "html.parser")
account_data = soup.find_all("script", id="account-landing-data")
account_data = r.json()
if len(account_data) == 0:
self.logged_in = False
else:
self.account_number = json.loads(account_data[0].contents[0])[
"accountNumber"
]
self.account_number = account_data[0]['accountNumber']
dashboard_data = self.session.get(
self.account_dashboard_url.format(accountNum=self.account_number)
).json()
Expand Down

0 comments on commit c31a881

Please sign in to comment.