Hi all,
I’m working on a project using the Django web framework.
I’ve tried to fetch data using the Python snippet from the TfL api portal but an import error returns (ImportError: Cannot import name ‘conn’ from ‘django’. Does anyone know which library conn sits?
Additionally, the snippet does not include the url which **I presume is just **
url = "https://api.tfl.gov.uk/Vehicle/EmissionSurcharge?vrm= ***** "?
The python snippet is below.
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
vrm = request.GET.get(‘vrm’)
headers = {
Request headers
‘Cache-Control’: ‘no-cache’,
}
params = urllib.parse.urlencode({
})
try:
conn.request(“GET”, “?%s” % params, headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print(“[Errno {0}] {1}”.format(e.errno, e.strerror))
####################################
Many thanks in advance.