def get_Auth():
USERNAME = User.get("1.0", END)
PASSWORD = Pass.get("1.0", END)
print(USERNAME)
print(PASSWORD)
url = 'https://ps.lphs.net/public/home.html'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.92 Safari/537.36 Vivaldi/1.6.689.34'}
g = requests.get(url)
soup = BeautifulSoup(g.content)
'Find The Values'
PSTOKEN = None
CONTEXTDATA = None
for input in soup.find_all('input')[0:1]:
PSTOKEN = input.get('value')
print(PSTOKEN)
for input in soup.find_all('input')[1:2]:
CONTEXTDATA = input.get('value')
print(CONTEXTDATA)
payload = {
'pstoken': PSTOKEN,
'contextData': CONTEXTDATA,
'dbpw': '',
'translator_username': '',
'translator_password': '',
'translator_ldappassword': '',
'returnUrl': 'https://ps.lphs.net/guardian/home.html',
'serviceName': 'PS Parent Portal',
'serviceTicket': '',
'pcasServerUrl': '\ /',
'credentialType': 'User Id and Password Credential',
'account': USERNAME,
'pw': PASSWORD,
'translatorpw': ''
}
r = requests.post(soup, data=payload)
print(r)
I am trying to log on to PowerSchool and scrape my grades from a login required page. I have been watching video after video and cannot figure out why it won't work. I have a Tkinter window that asks for my username and password then uses that to log onto that website. But when I run it all I get is the login page source code. Here are the pictures of the Network tab under inspect element.
I'm not sure what's wrong here, I've been looking into this for a while now. Thanks in advance!
I don't have an account to test, but multiple things are wrong in your current approach:
the password (
pwfield) is hashed via the following function (defined here):you cannot have the same token values every time you make a request. You have to get the token values from the actual form. Which means that you need to first "GET" the
home.html, extract the token values and then use them in your "POST" request.For the second problem, you might want to try things like
mechanizeormechanicalSoupthat would "auto-populate" the rest of the form fields automatically. They, though, cannot execute JavaScript which is quite important in this particular case.If you want to avoid dealing with all these problems, look into browser automation and
seleniumpackage.