I have this code:
import urllib.request, json
url = "https://api.wto.org/timeseries/v1/indicator_categories?lang=1"
hdr ={
# Request headers
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': '21cda66d75fc4010b8b4d889f4af6ccd',
}
req = urllib.request.Request(url, headers=hdr)
req.get_method = lambda: 'GET'
response = urllib.request.urlopen(req)
#print(response.getcode())
var = print(response.read().decode('ASCII'))
I tried this:
import pandas as pd
df = pd.DataFrame(var)
I am only getting an empty dataframe. The data is lost somehow. What am I doing wrong?
Also tried:
var = (response.read().decode('ASCII'))
This returns Byte String which I am not able to convert using eval():
eval(var)
NameError: name 'null' is not defined
I don't know how to proceed.