https://finance.google.com/finance/converter now redirects to https://www.google.com/search Have they changed the url ?
I found a workaround this url is working: https://finance.google.co.uk/bctzjpnsun/converter
you can view old pages by inserting this 'bctzjpnsun' in the url. For instance portfolio view with issues in the layout: https://finance.google.co.uk/bctzjpnsun/portfolio?action=view&pid=1&pview=sview
They are unfortunately in the process of removing it to push a new sleek layout www.google.com/finance without portfolio management features.
Obviously many are complaining but that did not help when they said the would terminate Google Reader loved by millions which means you should plan for an alternative.
EDIT: They should have communicated more on this. Most feature are easily replicable in google spreadsheets using =GOOGLEFINANCE
function.
In my case, I've found very useful Fixer.io and Open Exchange Rates API's. I've tested and compared both to Yahoo, XE and Google rates and the difference is about 3 to 5 cents!
Both API's offer free 1000 requests per month with 1 hour refresh. Payed plans offer more requests and more updates per hour. Open Exchange Rates also offers HTTPS requests with free plan.
Both API's responds in JSON format so it's very easy to parse the response data.
Open Exchange Rates https://openexchangerates.org/
Fixer.io https://fixer.io/
In free plans, both API's give you access to currency rates list only. Can't use currency exchange endpoints, so to be able to convert currencies, you need to apply this formula, toCurrency * (1 / fromCurrency)
$url = 'https://openexchangerates.org/api/latest.json?app_id=YOUR_APP_ID';
$useragent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0';
$rawdata = '';
if (function_exists('curl_exec')) {
$conn = curl_init($url);
curl_setopt($conn, CURLOPT_USERAGENT, $useragent);
curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, true);
$rawdata = curl_exec($conn);
curl_close($conn);
} else {
$options = array('http' => array('user_agent' => $useragent));
$context = stream_context_create($options);
if (function_exists('file_get_contents')) {
$rawdata = file_get_contents($url, false, $context);
} else if (function_exists('fopen') && function_exists('stream_get_contents')) {
$handle = fopen($url, "r", false, $context);
if ($handle) {
$rawdata = stream_get_contents($handle);
fclose($handle);
}
}
}
if ($rawdata) {
$rawdata = json_decode($rawdata);
$convertedCurrency = false;
$convertedCurrency = $rawdata->rates->$currB * (1 / $rawdata->rates->$currA);
}
To add to above answer, can confirm it works if you change url to .co.uk
https://finance.google.co.uk/finance/converter?a=1&from=USD&to=EUR
It's not working in Argentina, just redirects to Google Finance... (finance.google.com)
I guess you could use google search instead... just google something like "1 USD to ARS" (1 us dollar to argentine peso) and grab the result from there...
The search query would be something like https://www.google.com.ar/search?q=1+usd+to+ars and you would be grabbing the result from the corresponding DIV tag...
EDIT: In this particular case, the source code shows
<div class="vk_gy vk_sh">1 U.S. dollar =</div><div class="vk_ans vk_bk">20.2675314 Argentine pesos</div>
so you would grab the div with the vk_ans class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With