卷曲URL并将结果发布到Excel单元格中? [英] Curl URL and post results in Excel cell?
问题描述
我要在curl中包含200行(我想将其包含在curl(或任何类型的HTTP get)中,并在第二列中查看结果.
I have 200 rows in an Excel sheet that I would like to include in a curl (or any kind of HTTP get) and see the results in a second column.
**Column A**
123
456
789
012
...
我尝试使用Excel选项从外部网页获取数据,但是它似乎不适用于同一张纸上的多行.有没有办法将A列中的值附加到静态URL(即: http: //testurl.net/page.php?ID=[Column A]),以便将页面结果显示在B列中?我知道来自URL的响应将是仅显示几个单词的休息响应.
I have tried using the Excel option to get data from an external web page but it doesn't appear to work for multiple row on the same sheet. Is there a way for me to append the value in Column A to a static URL (ie:http://testurl.net/page.php?ID=[Column A]) so that the result of the page is shown in Column B? I know the response from the URL will be a rest response that will display only a couple words.
谢谢
推荐答案
您可以通过使用http请求对象来做到这一点:
you can do this by using a http request object:
Dim oRequest As Object
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "http://www.cboden.de"
oRequest.Send
MsgBox oRequest.ResponseText
如果您是代理人,则可以使用以下内容:
If you are behind a proxy you can use something like this:
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
,如果您想使用POST(而不是GET方法)将某些值传递到Web服务器,则可以尝试以下操作:
and if you want to use POST (instead of the GET method) to pass some values to the webserver, you can try this:
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
如果将其放入函数中,则可以在工作表中使用它:
if you put it into a function then you can use it in you worksheet:
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
在工作表中,您可以例如说:
within the worksheet you can then say for example:
=getCustomHyperlink("https://www.google.com/search?q=" & A1 )
如果您的搜索值在A1中
if your search value is in A1
这篇关于卷曲URL并将结果发布到Excel单元格中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!