Skip to content

Instantly share code, notes, and snippets.

View hari4274's full-sized avatar
🏠
Working from home

Hariprasath hari4274

🏠
Working from home
View GitHub Profile
@jamesevers
jamesevers / currency_converter.py
Created October 18, 2015 15:51
a currency converter that uses the yahoo finance API to find exchange rates
import urllib2
import json
def currencyConverter(from_value,target_value,currency_quantity):
yahoo_exchange_url = "https://query.yahooapis.com/v1/public/yql"
yahoo_query = 'select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20("'+currency_from+currency_to+'")'
yql_query_url = yql_base_url + "?q=" + yql_query + "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
try:
yql_response = urllib2.urlopen(yql_query_url)
try:
yql_json = json.loads(yql_response.read())