bramwell2010 bramwell2010 - 6 months ago 33
JSON Question

python error parsing json

I'm trying to parse the information found in this link here:

What I want to pull is the information under rowSet (so 0, 1, 2, etc will be one entry) enter image description here

Code I'm using:

import requests
urlPlayerLog = ""
responses = requests.get(urlPlayerLog)
dataGameLogs = responses.json()['resultSets'][0]['rowSet']

This was working for me for months and then one day I kept getting the following error:
enter image description here

Which made me think the issue was with dataGameLogs = responses.json()['resultSets'][0]['rowSet'] , but unsure why that is returning an error...

Ken Ken

The webpage might be expecting a web browser to request the data from the URL. Try adding a user-agent to your request.

import requests
HEADERS = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/31.0'}
urlPlayerLog = ""
responses = requests.get(urlPlayerLog, headers=HEADERS)
dataGameLogs = responses.json()['resultSets'][0]['rowSet']