I had used this code in the last years however google seemed to have changed some of their links. For some reason I am getting this error message:
"Input string was not in a correct format."
in following line:
decimal rate = System.Convert.ToDecimal(match.Groups[1].Value);
My code:
try
{
WebClient web = new WebClient();
string url = string.Format("https://www.google.com/finance/converter?a={2}&from={0}&to={1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount);
string response = web.DownloadString(url);
Regex regex = new Regex("rhs: \\\"(\\d*.\\d*)");
Match match = regex.Match(response);
decimal rate = System.Convert.ToDecimal(match.Groups[1].Value);
return rate;
}
catch
{
return 0;
}