Google 金融货币转换器不工作

Google finance Currency converter not working

我使用 google 财务的货币转换器代码无法正常工作

$amount="10";
      $from="USD";
      $to="INR";
    $data = file_get_contents("https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to");
    preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
    $converted = preg_replace("/[^0-9.]/", "", $converted[1]);
    echo number_format(round($converted, 3),2); exit;

我得到的结果是 0.00。

除了这个还有其他方法吗?

$amount="10";
$from="USD";
$to="INR";
$url = file_get_contents('https://free.currencyconverterapi.com/api/v5/convert?q=' . $from . '_' . $to . '&compact=ultra');
$json = json_decode($url, true);
$rate = implode(" ",$json);
$total = $rate * $amount;
$rounded = round($total); 
return $rounded;

使用此代码

google 的 URL 不再工作