如何将当前价格从网站导入 excel?
How do I import current price from site into excel?
目前我在excel中使用这个来导入股票价格:
这是来自 Yahoo Finance 的,使用简单,我可以按 CTRL-ALT-F9 自动更新所有单元格并将最新价格填充到单元格中。
我如何从另一个站点导入不断变化的号码?
我尝试使用 "Data>Get & Transform Data>From Web" 等方法但没有成功。
我想要完成的是让一个 excel 单元格显示 http://preev.com/ 上的当前价格,并在我按 CTRL-ALT-F9[=13= 时更新到最新价格]
我看到了这个解决方案并且看起来与你的问题相同:
excel-convert-external-links-to-values
如果你不喜欢这种方法,我会搜索这样一种不同的方法
这里是UDF
写成VBA
到return当前的比特币现货价格。如所写,它将使用 ctrl-alt-F9 进行更新。默认 return 是 spot
价格。它还将 return buy
或 sell
加上适当的参数。
不要忘记设置引用,如代码所示。
在工作表上:
=CurrBitCoinPrice()
常规模块
Option Explicit
'Set Reference to: Microsoft WinHTTP services, Version 5.1
' Microsoft VBScript Regular Expressions 5.5
Function CurrBitCoinPrice(Optional BSSp As Long = 3) as Currency
'1: Buy
'2: Sell
'3: Spot
Application.Volatile
Dim httpRequest As WinHttpRequest
Dim sResponse(2) As String
Dim RE As Object, MC As Object
Dim sType
Const sInfo As String = "?currency=USD"
Dim vRes As Variant
Dim I As Long
sType = Array("buy", "sell", "spot")
Const sUrl As String = "https://api.coinbase.com/v2/prices/"
For I = 0 To 2
Set httpRequest = New WinHttpRequest
With httpRequest
.Open "Get", sUrl & sType(I) & sInfo
.Send
.WaitForResponse
sResponse(I) = .ResponseText
End With
Set httpRequest = Nothing
Next I
Set RE = New RegExp
With RE
.Pattern = "\d*\.?\d+"
.Global = False
End With
ReDim vRes(0 To 1, 1 To 3)
vRes(0, 1) = "Buy"
vRes(0, 2) = "Sell"
vRes(0, 3) = "Spot"
For I = 0 To 2
If RE.Test(sResponse(I)) = True Then
Set MC = RE.Execute(sResponse(I))
vRes(1, I + 1) = MC(0)
End If
Next I
CurrBitCoinPrice = vRes(1, BSSp)
End Function
目前我在excel中使用这个来导入股票价格:
这是来自 Yahoo Finance 的,使用简单,我可以按 CTRL-ALT-F9 自动更新所有单元格并将最新价格填充到单元格中。
我如何从另一个站点导入不断变化的号码? 我尝试使用 "Data>Get & Transform Data>From Web" 等方法但没有成功。
我想要完成的是让一个 excel 单元格显示 http://preev.com/ 上的当前价格,并在我按 CTRL-ALT-F9[=13= 时更新到最新价格]
我看到了这个解决方案并且看起来与你的问题相同:
excel-convert-external-links-to-values
如果你不喜欢这种方法,我会搜索这样一种不同的方法
这里是UDF
写成VBA
到return当前的比特币现货价格。如所写,它将使用 ctrl-alt-F9 进行更新。默认 return 是 spot
价格。它还将 return buy
或 sell
加上适当的参数。
不要忘记设置引用,如代码所示。
在工作表上:
=CurrBitCoinPrice()
常规模块
Option Explicit
'Set Reference to: Microsoft WinHTTP services, Version 5.1
' Microsoft VBScript Regular Expressions 5.5
Function CurrBitCoinPrice(Optional BSSp As Long = 3) as Currency
'1: Buy
'2: Sell
'3: Spot
Application.Volatile
Dim httpRequest As WinHttpRequest
Dim sResponse(2) As String
Dim RE As Object, MC As Object
Dim sType
Const sInfo As String = "?currency=USD"
Dim vRes As Variant
Dim I As Long
sType = Array("buy", "sell", "spot")
Const sUrl As String = "https://api.coinbase.com/v2/prices/"
For I = 0 To 2
Set httpRequest = New WinHttpRequest
With httpRequest
.Open "Get", sUrl & sType(I) & sInfo
.Send
.WaitForResponse
sResponse(I) = .ResponseText
End With
Set httpRequest = Nothing
Next I
Set RE = New RegExp
With RE
.Pattern = "\d*\.?\d+"
.Global = False
End With
ReDim vRes(0 To 1, 1 To 3)
vRes(0, 1) = "Buy"
vRes(0, 2) = "Sell"
vRes(0, 3) = "Spot"
For I = 0 To 2
If RE.Test(sResponse(I)) = True Then
Set MC = RE.Execute(sResponse(I))
vRes(1, I + 1) = MC(0)
End If
Next I
CurrBitCoinPrice = vRes(1, BSSp)
End Function