Powerschool Login Form Data

278 Views Asked by At

I'm trying to login to PowerSchool to scrape my grades. Whenever I run the code it gives me the login pages HTML code instead of the secured pages HTML code.

Question 1: How do I get the value of the 3 fields that change labeled 'this changes' in the code above, and submit it to the current post?

Question 2: Am I required to add anything in the code for my password that gets hashed each post.

https://ps.lphs.net/public/home.html <--- Link to login page for HTML code.

Picture of form data on chrome

import requests


payload = {
    'pstoken': 'this changes',
    'contextData': 'this changes',
    'dbpw': 'this changes',
    'translator_username': '',
    'translator_password': '',
    'translator_ldappassword': '',
    'serviceName':' PS Parent Portal',
    'serviceTicket':'',
    'pcasServerUrl':' /',
    'credentialType':'User Id and Password Credential',
    'account':'200276',
    'pw':'my password',
    'translatorpw':''
}

head = {'User-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3180.0 Safari/537.36'}

with requests.Session() as s:
    p = s.post('https://ps.lphs.net/public/', data=payload, headers=head)

    r = s.get('https://ps.lphs.net/guardian/home.html')
    print(r.text)

EDIT 1 :

    s.headers = {
        'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3180.0 Safari/537.36'}

    p = s.get('https://ps.lphs.net/guardian/home.html')
    print(p.text)

    r = s.post('https://ps.lphs.net/guardian/home.html', data=payload,
               headers={'Content-Type': 'application/x-www-form-urlencoded',
                        'Referer': 'https://ps.lphs.net/public/home.html'})

    print(r.text)
1

There are 1 best solutions below

2
SIM On

Give this a shot. It should fetch you the valid response:

import requests

payload = {
    'pstoken': 'this changes',
    'contextData': 'this changes',
    'dbpw': 'this changes',
    'translator_username': '',
    'translator_password': '',
    'translator_ldappassword': '',
    'serviceName':' PS Parent Portal',
    'serviceTicket':'',
    'pcasServerUrl':' /',
    'credentialType':'User Id and Password Credential',
    'account':'200276',
    'pw':'my password',
    'translatorpw':''
}

with requests.Session() as s:
    s.headers={'User-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3180.0 Safari/537.36'}
    r = s.post('https://ps.lphs.net/guardian/home.html',data=payload,
                headers={'Content-Type': 'application/x-www-form-urlencoded',
                        'Referer':'https://ps.lphs.net/public/home.html'})
    print(r.text)

Btw, change the parameter in payload (if needed) to get logged in.