AppleScript 上的curl

发布于 2024-12-01 07:40:57 字数 1199 浏览 0 评论 0原文

这是我的脚本,但我在从 URL 获取响应时遇到问题。

if newChromeValue contains "http://" then
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
            "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    else
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=http://" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
            "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    end if



    set URLChromeResponse to do shell script URLChromerequest
    return URLChromeResponse

当我运行此脚本时,它显示只有第一个参数通过服务器发送,即“body”。其他的似乎丢失了......

但是,如果我返回“URLChromerequest”,我可以看到 URL 是相应的形式,如果我将其粘贴到网络浏览器,它工作正常......

可能是什么问题?

This is my script but I'm having problem on getting the response from the URL.

if newChromeValue contains "http://" then
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
            "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    else
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=http://" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
            "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    end if



    set URLChromeResponse to do shell script URLChromerequest
    return URLChromeResponse

When I run this script , it shows that only the first parameter is sent over the server which is 'body'. The others seems to be missing...

however, if I return the 'URLChromerequest' I can see that the URL is form accordingly and if I paste it to the web browser, it works perfectly..

WHat might be the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热鲨 2024-12-08 07:40:57

使用 quoted form 引用 url 可能会有所帮助:

if newChromeValue does not start with "http://" then
    set newChromeValue to "http://" & newChromeValue
end

set URLChromerequest to "curl --url " & quoted form of ¬
    ("http://0.0.0.0:54321/cat?body=" & myBodyEnc & ¬
    "&url=" & newChromeValue & ¬
    "&title=" & pgTitlEnc & ¬
    "&keywords=" & mykeywordEnc & ¬
    "&description=" & myDescriptionEnc & ¬
    "&type=body" & ¬
    "&reqtype=main/")

set URLChromeResponse to do shell script URLChromerequest

虽然不确定,但 url 似乎被 shell 分割了

It might help to quote the url using quoted form of:

if newChromeValue does not start with "http://" then
    set newChromeValue to "http://" & newChromeValue
end

set URLChromerequest to "curl --url " & quoted form of ¬
    ("http://0.0.0.0:54321/cat?body=" & myBodyEnc & ¬
    "&url=" & newChromeValue & ¬
    "&title=" & pgTitlEnc & ¬
    "&keywords=" & mykeywordEnc & ¬
    "&description=" & myDescriptionEnc & ¬
    "&type=body" & ¬
    "&reqtype=main/")

set URLChromeResponse to do shell script URLChromerequest

Dont' know for sure though, but it would seem that the url is being split by the shell

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文