问题
I'm trying to access a web page with python requests library.
The url is here:
https://acs.leagueoflegends.com/v1/stats/game/WMC2TMNT1/210029?gameHash=50ee0d42d77ae4d9
The python is fairly simple, ''' requests.get(url)
When I'm not logged in to riot games, this returns the following status code:
{"httpStatus":429,"errorCode":"CLIENT_RATE_LIMITED"}
So I tried creating a session via the following code:
login_url ='https://auth.riotgames.com/login#client_id=rso-web-client-prod&login_hint=na&redirect_uri=https%3A%2F%2Flogin.leagueoflegends.com%2Foauth2-callback&response_type=code&scope=openid&state=bQ4XWVHrRzMPJYznFtQMbFav6bWcr_pKw3db7JXTULc&ui_locales=en'
with requests.Session() as session:
response = session.get(login_url, auth = HTTPBasicAuth(user, pwd))
print('response:', response)
This seems to work and returns a 200 page response. But when I try to then access the url within the session (using the below code), it's back to returning that 429.
user = 'StackOverflow1218'
pwd = 'helpme0biwankenobi'
with requests.Session() as session:
response = session.get(login_url, auth = HTTPBasicAuth(user, pwd))
print('response:', response)
url = 'https://acs.leagueoflegends.com/v1/stats/game/WMC2TMNT1/210029?gameHash=50ee0d42d77ae4d9'
res2 = session.get(url)
print(res2)
I can't figure out why the permissions aren't persisting in the session and I dont know enough about how http requests work to provide a good hypothesis about what's going on. Any help or suggestions would be appreciated. I set up the username/password provided in this post specifically to troubleshoot the issue so there isn't any personal info being shared.
来源:https://stackoverflow.com/questions/65364166/python-requests-library-returning-429-on-1-request