python 3.x - Inserting date into URL and Getting currency data for that date -
python 3.x - Inserting date into URL and Getting currency data for that date -
i trying write function gathers currency info date https://openexchangerates.org/ , homecoming dicitionary. bit stuck on how insert date in url @ point says yyyy-mm-dd , how onto python.
any help hugely appreciated
my code have far follows:
def _fetch_exrates(date): import json import urllib.request f = urllib.request.urlopen('http://openexchangerates.org/api/historical/yyyy-mm-dd.json?app_id=188bd7b8d2634e4cb0602ab5b3c223e7') charset = f.info().get_param('charset', 'utf8') info = f.read() decoded = json.loads(data.decode(charset)) print(json.dumps(decoded, indent=4)) import datetime print('please year in form of yyyy , month mm , day dd') = int(input('choose year :',)) b = int(input('choose month :',)) c = int(input('choose day :',)) date = datetime.date(a,b,c) print(date)
def _fetch_exrates(year,month,day): import json import urllib.request f = urllib.request.urlopen('http://openexchangerates.org/api/historical/'+year+'-'+month+'-'+day+'.json?app_id=188bd7b8d2634e4cb0602ab5b3c223e7') charset = f.info().get_param('charset', 'utf8') info = f.read() decoded = json.loads(data.decode(charset)) print(json.dumps(decoded, indent=4)) print('please year in form of yyyy , month mm , day dd') year = raw_input('choose year :',) month = raw_input('choose month :',) day = raw_input('choose day :',) _fetch_exrates(year,month,day)
then using strings above build it.
date python-3.x currency currency-exchange-rates
Comments
Post a Comment