gpt4 book ai didi

json - curl URL 并在 Excel 单元格中发布结果?

转载 作者:行者123 更新时间:2023-12-02 07:52:35 26 4
gpt4 key购买 nike

我的 Excel 工作表中有 200 行,我希望将其包含在curl(或任何类型的 HTTP get)中,并在第二列中查看结果。

**Column A**
123
456
789
012
...

我尝试使用 Excel 选项从外部网页获取数据,但它似乎不适用于同一张纸上的多行。有没有办法让我将 A 列中的值附加到静态 URL(即:http://testurl.net/page.php?ID=[Column A]),以便页面的结果显示在 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

如果您使用代理,您可以使用如下内容:

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 方法)将一些值传递给网络服务器,您可以尝试以下操作:

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

如果将其放入函数中,则可以在工作表中使用它:

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

在工作表中,您可以说例如:

=getCustomHyperlink("https://www.google.com/search?q=" & A1 )

如果您的搜索值在 A1 中

关于json - curl URL 并在 Excel 单元格中发布结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26681866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com