Google finance converter stopped working or changed its url? [closed]

﹥>﹥吖頭↗ 提交于 2019-12-28 13:35:11

问题


https://finance.google.com/finance/converter now redirects to https://www.google.com/search Have they changed the url ?


回答1:


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.




回答2:


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



回答3:


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.




回答4:


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.

More info here:

Open Exchange Rates https://openexchangerates.org/

Fixer.io https://fixer.io/

How to convert currencies using free plan?

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)

Using Open Exchange Rates and PHP:

$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);
}


来源:https://stackoverflow.com/questions/49324112/google-finance-converter-stopped-working-or-changed-its-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!