import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse
import csv
from io import StringIO
import pandas as pd
import os
from zipfile import ZipFile
from pprint import pprint, pformat
my_url = 'http://www.bankofcanada.ca/stats/results/csv'
data = urllib.parse.urlencode({'lookupPage': 'lookup_yield_curve.php',
    'startRange': '1986-01-01', 'searchRange': 'all'})
request = urllib.request.Request(my_url, data)
result = urllib.request.urlopen(request)
zipdata = result.read()
zipfile = ZipFile(StringIO(zipdata))
print('zipfile.namelist(): {}'.format(zipfile.namelist()))
Attribute Error when extracting data from a URL with a zip file