Having trouble logging in
Closed this issue · 4 comments
Hi all, please bear with me as this is my first project within python and I am learning as I go. If this is not the right place to post, i apologize.
I successfully was able to scrape the information I needed back in March, now that I am touching this project again, i have been having trouble getting past the login.
My email and password are confirmed correct, and i upgraded to 0.4.0
Here is my code:
import kenpompy
import numpy as np
import pandas as pd
from kenpompy.utils import login
Your KenPom login credentials
email = "censored"
password = "censored"
browser = login(email, password)
import kenpompy.summary as kp
I cut off the rest of the code as that portion is working as written...
And here is the error i am receiving:
Traceback (most recent call last):
File "c:\Users\Mattk\Documents\code\scrape kenpom.py", line 12, in
browser = login(email, password)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mattk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\kenpompy\utils.py", line 39, in login
raise Exception('Logging in failed - check your credentials')
Exception: Logging in failed - check your credentials
If anyone could assist it would be much appreciated, thank you.
Sorry, it looks like you're logging in twice and only getting the error the second time. Is that the case?
I really appreciate your response and thank you for this project.
it could be the case, but from what i can tell i am only logging in once. This is my original code below that worked previously.
import kenpompy
import numpy as np
import pandas as pd
from kenpompy.utils import login
Your KenPom login credentials
email = "censored"
password = "censored"
browser = login(email, password)
import kenpompy.summary as kp
Returns a pandas dataframe containing the efficiency and tempo stats for the current season (https://kenpom.com/summary.php).
eff_stats = kp.get_efficiency(browser)
team_stats = kp.get_teamstats(browser)
four_f = kp.get_fourfactors(browser)
#KEN POM DATA FRAMES
df = pd.DataFrame(eff_stats)
tdf = pd.DataFrame(team_stats)
fdf = pd.DataFrame(four_f)
moddf = df[['Team', 'Tempo-Adj', 'Tempo-Raw', 'Avg. Poss Length-Offense', 'Avg. Poss Length-Defense', 'Off. Efficiency-Adj', 'Def. Efficiency-Adj']]
#EFFICIENCY STATS KENPOM MUST CONVERT DATA TO NUMERIC VALUES, ORIGINALLY SCRAPED AS X VALUES
ta = 'Tempo-Adj'
df[ta] = pd.to_numeric(df[ta])
tr = 'Tempo-Raw'
df[tr] = pd.to_numeric(df[tr])
apld = 'Avg. Poss Length-Defense'
df[apld] = pd.to_numeric(df[apld])
aplo = 'Avg. Poss Length-Offense'
df[aplo] = pd.to_numeric(df[aplo])
oeadj = 'Off. Efficiency-Adj'
df[oeadj] = pd.to_numeric(df[oeadj])
oeraw = 'Off. Efficiency-Raw'
df[oeraw] = pd.to_numeric(df[oeraw])
deadj = 'Def. Efficiency-Adj'
df[deadj] = pd.to_numeric(df[deadj])
deraw = 'Def. Efficiency-Raw'
df[deraw] = pd.to_numeric(df[deraw])
#D1 AVERAGES
taavg = df[ta].mean()
travg = df[tr].mean()
apldavg = df[apld].mean()
aploavg = df[aplo].mean()
oeadjavg = df[oeadj].mean()
oerawavg = df[oeraw].mean()
deadjavg = df[deadj].mean()
derawavg = df[deraw].mean()
#Create Data frame out of averages
avgdf = pd.DataFrame({'Adjusted Tempo': taavg , 'Raw Tempo': travg , 'Average Def. Poss. Length' : apldavg , 'Average Off. Poss. Length' : aploavg , 'Off. Eff. Adj. Avg' : oeadjavg , 'Off. Eff. Raw Avg.' : oerawavg , 'Def. Eff. Adj. Avg' : deadjavg , 'Def. Eff. Raw Avg.' : derawavg}, index=[0])
Are you sure that your subscription has not lapsed and that your credentials are correct? I cannot reproduce your error with valid credentials.
I ended up sending the file to my other computer and it worked fine. I will figure out the issue with the one I am using. Sorry to bother, I appreciate your time! I will close this