我在网上搜索过但无法找到我正在寻找的确切内容 - 这可能是因为它不存在,但无论如何我都会在这里问...
我想使用一个非常简单的使用VB编写,我曾经使用过诸如RSS提要之类的东西,但仅限于HTML环境。我想知道是否有办法将表格的一部分作为美元 - > GBP转换器,使用实时汇率。这可能吗?如果是这样,有没有人知道从中获取实时源的好来源? 任何想法,代码,建议和批评都是受欢迎的。 谢谢你的时间。 校准。
答案 0 :(得分:0)
最简单的方法是使用此函数查询Yahoo货币转换器:
Public Function GetHTML(ByVal sURL As String) As String
'Function returns the contents of the web page at sURL
'(or the contents of the 404/error info, if sURL is
'invalid, incorrectly formatted, etc.)
Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.ServerXmlHttp")
xmlHttp.Open "GET", sURL, False
xmlHttp.send
GetHTML = xmlHttp.responseText
Set xmlHttp = Nothing
End Function
请注意,它使用的是ServerXmlHttp
,而不仅仅是XmlHttp
。这是因为后者在我尝试时会返回Access denied
错误,我不知道为什么。
使用以下内容从表单代码中调用它:
lblRate.caption = GetHTML("http://finance.yahoo.com/d/quotes.csv?&f=l1&s=USDGBP=X")
注意:强>
AFAICT没有关于Yahoo API的任何官方文档。但是如果你在网上搜索,有很多例子可供使用。