我正在编写vba以打开中央银行的网站并输入值并提取数据,我通常在邮件网站,巴西银行等处这样做...
()中央银行
<Input type = "text" name = "valueConverter" maxlength = "17" size "20" value onkeypress = "return (MascaraMoeda (this, '.', ',', Event)
此网站的元素是:
Date Status Product
2016-02-01 1 Car
2016-02-01 1 House
2016-02-01 2 Car
2016-02-01 2 Car
2016-02-01 2 House
2016-03-02 3 House
2016-03-02 2 House
有谁知道怎么做?
答案 0 :(得分:0)
<强> TL;博士; 强>
我不能将此标记为副本,因为我没有接受答案,我在哪里发布了类似问题的答案。
不确定协议只是在评论中发布链接并不意味着它会再次被发现。
我的完整答案在这里:the manual
总结:
您可以使用Excel Web Query Submit Issues。
使用汇率 - bcb.gov.br Open Data Portal发送转换率的JSON回复请求。
通过收到的回复,以及其他方法,您可以:
为简洁起见,我会在这里给你第二种方法,你可以查看我对这两种方法的其他答案:
Public Sub GetInfo2()
Dim strURL As String, strJSON As String, item As Variant, http As Object, json As Object
Const TARGET_CURRENCY As String = "USD"
Const START_DATE As String = "06-13-2018"
Const END_DATE As String = "06-13-2018"
strURL = "https://olinda.bcb.gov.br/olinda/service/PTAX/version/v1/odata/ExchangeRatePeriod(moeda=@moeda,dataInicial=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?%40moeda=%27" & TARGET_CURRENCY & "%27&%40dataInicial=%27" & START_DATE & "%27&%40dataFinalCotacao=%27" & END_DATE & "%27&%24format=json"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", strURL, False
http.send
strJSON = http.responseText
Dim Matches As Object
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = """cotacaoCompra"":\d{1,}.\d{1,}" 'The pattern I really wanted, "(?<=""cotacaoCompra"":)\d{1,}.\d{1,}", doesn't appear to be supported
If Not .test(strJSON) Then Exit Sub
Set Matches = .Execute(strJSON)
Dim match As Object
For Each match In Matches
Debug.Print Replace(match, """cotacaoCompra"":", vbNullString)
Next
End With
End Sub