现在,我在 C#(服务器)中找到了解决方案,Razor 在客户端使用它[基于 RSS URL]:
public float getExchangeRate_ETH_To_ILS()
{
float exchangeRate;
string[] words;
int indexOfExchangeRate;
using (var client = new WebClient())
{
try
{
var htmlPage = client.DownloadString("https://coinyep.com/he/rss/ETH-ILS.xml");
words = htmlPage.Split(' ');
indexOfExchangeRate = words.IndexOf("ILS");
exchangeRate = (float)Convert.ToDouble(words[indexOfExchangeRate - 1]);
}
catch(Exception e)
{
exchangeRate = -1;
}
}
return exchangeRate;
}
在客户端,我通过模型(Razor)使用这个功能:
var cal1 = @Model.getExchangeRate_ETH_To_ILS();
但是有一个风险:如果RSS的模板改变了,我们就有麻烦了。