I stop working with Python and web scrapers. And I can’t even achieve the first step of scraping the site: login. Before trying to use mechanize or selenium , I want to use requests first. Can anybody help me?
The website I was trying to access is here .
For those who don’t have an account and want to help me, I will provide information obtained through Chrome.
First POST: POST_1.JPG . Second POST: POST_2.JPG
And here is my code for trying to login:
import requests s = requests.Session() headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'} payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'submit.x': '21', 'submit.y': '12'} s.post('https://ssologin.cuny.edu/oam/server/auth_cred_submit', data = payload, headers = headers) target_page = s.get('https://home.cunyfirst.cuny.edu/psp/cnyepprd/EMPLOYEE/EMPL/h/?tab=DEFAULT', headers = headers) if 'login' in target_page.url: print("Failed to Login") else: print("Logged in Successfully!")
Thanks!!!
source share