AAA*_*AAA 5 excel vba json curl
我想在curl中包含200行(我想将其包含在curl中(或任何类型的HTTP get),并在第二列中查看结果。
**Column A**
123
456
789
012
...
Run Code Online (Sandbox Code Playgroud)
我尝试使用Excel选项从外部网页获取数据,但是它似乎不适用于同一张纸上的多行。有没有办法将A列中的值附加到静态URL(即:http : //testurl.net/page.php?ID=[ A列]),以使页面结果显示在Column中B?我知道来自URL的响应将是仅显示几个单词的其余响应。
谢谢
您可以使用http请求对象来做到这一点:
Dim oRequest As Object
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "http://www.cboden.de"
oRequest.Send
MsgBox oRequest.ResponseText
Run Code Online (Sandbox Code Playgroud)
如果您使用代理,则可以使用以下方法:
Const HTTPREQUEST_PROXYSETTING_PROXY = 2
Dim oRequest As Object
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.setProxy HTTPREQUEST_PROXYSETTING_PROXY, "http://proxy.intern:8080"
oRequest.Open "GET", "http://www.cboden.de"
oRequest.Send
MsgBox oRequest.ResponseText
Run Code Online (Sandbox Code Playgroud)
并且如果您想使用POST(而不是GET方法)来将某些值传递给Web服务器,则可以尝试以下操作:
Dim oRequest As Object
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "POST", "http://www.cboden.de/misc/posttest.php"
oRequest.SetRequestHeader "Content-Typ", "application/x-www-form-urlencoded"
oRequest.Send "var1=123&anothervar=test"
MsgBox oRequest.ResponseText
Run Code Online (Sandbox Code Playgroud)
如果将其放入函数中,则可以在工作表中使用它:
Function getCustomHyperlink(ByVal pURL As String) As String
Dim oRequest As Object
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", pURL
oRequest.Send
getCustomHyperlink = oRequest.ResponseText
End Function
Run Code Online (Sandbox Code Playgroud)
在工作表中,您可以例如说:
=getCustomHyperlink("https://www.google.com/search?q=" & A1 )
Run Code Online (Sandbox Code Playgroud)
如果您的搜索值在A1中
| 归档时间: |
|
| 查看次数: |
11254 次 |
| 最近记录: |