kevinvi8
kevinvi8

Reputation: 321

Trying to Log In to ESPN Using Python Requests

I am trying to get an application set up so that I can scrape Fantasy Football data from my League on the ESPN Fantasy website. In order to make this function, I am trying to learn how to sign into a website using the Requests module on Python, but I am running into an issue. While going through the HTTP Network stuff on the ESPN login page, I manage to find the "POST" Request URL, but that page seems to be intentionally set up to stop this exact type of attempt (or perhaps I am just too inexperienced to figure it out).

The URL that is shown in the photo below takes you to a blank web page with the following text:

{"data":null,"error":{"keyCategory":"FAILURE_BY_DESIGN","conversationId":null,"correlationId":"d2f53819-03f1-4247-832d-210bbe112053","errors":[{"code":"AUTHORIZATION_INVALID_OR_EXPIRED_TOKEN","category":"FAILURE_BY_DESIGN","inputName":null,"errorId":"47126869-c7d0-4f79-b7cd-7797cda2f57a","timestamp":"2021-09-20T14:58:34.845-0700","data":null,"developerMessage":null,"content":null}]}}

Does anyone know if there is a better way to try and login to a page like this using Python and requests?

enter image description here

import requests
import json


def login(mail, password):
    s = requests.session()
    payload = {
        'email': mail,
        'password': password
    }
    res = s.post('https://registerdisney.go.com/jgc/v6/client/ESPN-ONESITE.WEB-PROD/guest/login?langPref=en-US', json=payload)
    s.headers.update({'authorization': json.loads(res.content)})
    print (res.content)
    return s

session = login('myemail', 'my password')

Upvotes: 0

Views: 375

Answers (0)

Related Questions