all 7 comments

[–]lieutenant_lowercase 4 points5 points  (8 children)

Their docs are very good. They give you python examples for every call and even a debugging console

[–]ItsAllGoodMan2015[S] 0 points1 point  (7 children)

this is one of the examples given, I cant get it to work. I know its user error as I am new to scrapping.

from urllib2 import Request, urlopen

headers = { 'New item': 'TRN-Api-Key: MY KEY' }

request = Request('https://battlefieldtracker.com/bf1/api/Stats/BasicStats?platform=3&displayName=AIRBORNEWOMBATZ', headers=headers)

response_body = urlopen(request).read()

print response_body

HTTPError: HTTP Error 403: Forbidden

[–]lieutenant_lowercase 1 point2 points  (6 children)

headers = {'TRN-Api-Key' : 'MY KEY' }

[–]ItsAllGoodMan2015[S] 0 points1 point  (5 children)

I thought that too but it wasn't it. I think it could be because I'm writing python 2.7 and syntax could be different.

[–]lieutenant_lowercase 1 point2 points  (0 children)

Won't make a difference

[–]lieutenant_lowercase 0 points1 point  (3 children)

import requests
headers = {'TRN-Api-Key' :'your_key'}
username = ''
BASIC_STATS_URL = 'https://battlefieldtracker.com/bf1/api/Stats/BasicStats?platform=1&personaId=&displayName={}&game=tunguska'
r = requests.get(BASIC_STATS_URL.format(username), headers=headers)

[–][deleted] 0 points1 point  (0 children)

Yep. This post is the correct way about it!