HTTP error 403 on this code:

Diotallevi de 독일

Beginning to work with api version2...

adjusted a code snippet from the old documentation to python3 and api2 but it doesn't work, I hit a 403 wall :-(

What's wrong?

import urllib.request

import json

API_KEY = ...

url = 'https://www.lingq.com/api/v2/languages/'

headers={'Authorization': 'Token ' + API_KEY}

req = urllib.request.Request(url, headers=headers)

with urllib.request.urlopen(req) as response:

lang_json = response.read()

languages = json.loads(lang_json)

for language in languages:

print (language)

April 2018
  • 관리자
    akaromank ua 우크라이나

    you should try requests library instead:

    import requests

    print(requests.get('https://www.lingq.com/api/v2/languages/', headers={'Authorization': 'Token ' + API_KEY}).json())

    April 2018
    • Diotallevi de 독일

      Thank you very much, this worked (leaving out the ; after the URL) :-)

      April 2018