Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AppleScript cURL和解析URL_Applescript_Automator_Osx Snow Leopard - Fatal编程技术网

AppleScript cURL和解析URL

AppleScript cURL和解析URL,applescript,automator,osx-snow-leopard,Applescript,Automator,Osx Snow Leopard,我正在处理自动化工作流,我正在将URL列表传递给“RunAppleScript”,我需要获取每个页面上的内容,连接并将其传递给BBedit(或任何其他文本编辑器) 运行时{input,parameters} 告诉应用程序“BBEdit” 激活 将astid设置为AppleScript的文本项分隔符 将startHere设置为“” 将stopHere设置为“” 用输入中的一个项目重复 将blurb0设置为(执行shell脚本“curl”和anItem) 将AppleScript的文本项分隔符设置为

我正在处理自动化工作流,我正在将URL列表传递给“RunAppleScript”,我需要获取每个页面上的内容,连接并将其传递给BBedit(或任何其他文本编辑器)

运行时{input,parameters}
告诉应用程序“BBEdit”
激活
将astid设置为AppleScript的文本项分隔符
将startHere设置为“”
将stopHere设置为“”
用输入中的一个项目重复
将blurb0设置为(执行shell脚本“curl”和anItem)
将AppleScript的文本项分隔符设置为startHere
将blurb1设置为blurb0的文本项2
将AppleScript的文本项分隔符设置为stop here
将blurb2设置为blurb1的文本项1
将AppleScript的文本项分隔符设置为astid
返回blurb2
嘟嘟声
结束重复
结束语
终点

当前代码仅正确地从第一个URL获取内容。有人能解决这个问题吗?

这个子程序可能就是您所需要的(如果您使用的是Safari)

使用以下命令调用它:

repeat with anItem in input
    getSource(input)
end repeat

我希望这有帮助

因为您在
重复输入中的某个项目的
循环中,它完成了第一个项目的所有工作,
返回
退出循环,实际上是整个自动操作。我想您从未从脚本中听到过
嘟嘟声;-)

另一方面,我想知道你为什么要BBEdit为你做卷曲和排序工作。所有被调用的处理程序都不属于BBEdit

我认为您的处理程序应该如下所示:

on run {input, parameters}

    -- define a few parameters
    set astid to AppleScript's text item delimiters
    set startHere to "<tbody>"
    set stopHere to "</tbody>"

    -- define a list to store all found content
    set allFoundContent to {}

    repeat with anItem in input

        set blurb0 to (do shell script "curl " & anItem)
        set AppleScript's text item delimiters to startHere
        set blurb1 to text item 2 of blurb0
        set AppleScript's text item delimiters to stopHere

        -- put the found content at the end of the list
        set end of allFoundContent to text item 1 of blurb1

        set AppleScript's text item delimiters to astid

    end repeat

    -- from here you have three possibilities:
    -- 1. return the list to next Automator action (uncomment the next line):

    -- return allFoundContent


    -- 2. concatenate the list with a delimiter you like (here return & "------" & return)
    -- and give it to your preferred text editor from this point (uncomment the next lines):

    -- set AppleScript's text item delimiters to return & "------" & return
    -- tell application "TextEdit"
    --     make new document with properties {text: allFoundContent as text}
    -- end tell
    -- set AppleScript's text item delimiters to astid


    -- 3. concatenate the list with a delimiter you like (here return & "------" & return)
    -- and give it to the next workflow step, maybe a BBEdit action waiting for a string? (uncomment the next lines):

    -- set AppleScript's text item delimiters to return & "------" & return
    -- set returnString to allFoundContent as text
    -- set AppleScript's text item delimiters to astid
    -- return returnString


    -- Next decision (for choice 1 or 2):
    -- What do you want to give to next Automator action?

    -- you can pass your input (the given URLs) (uncomment next line):
    -- return input

    -- or your result list (uncomment next line):
    -- return allFoundContent
end run
运行时{input,parameters}
--定义几个参数
将astid设置为AppleScript的文本项分隔符
将startHere设置为“”
将stopHere设置为“”
--定义一个列表来存储所有找到的内容
将allFoundContent设置为{}
用输入中的一个项目重复
将blurb0设置为(执行shell脚本“curl”和anItem)
将AppleScript的文本项分隔符设置为startHere
将blurb1设置为blurb0的文本项2
将AppleScript的文本项分隔符设置为stop here
--将找到的内容放在列表的末尾
将allFoundContent的结尾设置为blurb1的文本项1
将AppleScript的文本项分隔符设置为astid
结束重复
--在这里,您有三种可能性:
-- 1. 将列表返回到下一个自动机操作(取消注释下一行):
--返回allFoundContent
-- 2. 用您喜欢的分隔符连接列表(此处为return&“----”&return)
--并从此处将其交给您首选的文本编辑器(取消注释下一行):
--将AppleScript的文本项分隔符设置为return&“-----”和return
--告诉应用程序“文本编辑”
--创建属性为{text:allFoundContent as text}的新文档
--结束语
--将AppleScript的文本项分隔符设置为astid
-- 3. 用您喜欢的分隔符连接列表(此处为return&“----”&return)
--并将其交给下一个工作流步骤,可能是BBEdit操作等待字符串?(取消对下一行的注释):
--将AppleScript的文本项分隔符设置为return&“-----”和return
--将returnString设置为allFoundContent作为文本
--将AppleScript的文本项分隔符设置为astid
--返回字符串
--下一个决定(选择1或2):
--您希望为下一个自动机操作提供什么?
--您可以传递输入(给定URL)(取消注释下一行):
--返回输入
--或您的结果列表(取消注释下一行):
--返回allFoundContent
终点
你好,迈克尔/汉堡

repeat with anItem in input
    getSource(input)
end repeat
on run {input, parameters}

    -- define a few parameters
    set astid to AppleScript's text item delimiters
    set startHere to "<tbody>"
    set stopHere to "</tbody>"

    -- define a list to store all found content
    set allFoundContent to {}

    repeat with anItem in input

        set blurb0 to (do shell script "curl " & anItem)
        set AppleScript's text item delimiters to startHere
        set blurb1 to text item 2 of blurb0
        set AppleScript's text item delimiters to stopHere

        -- put the found content at the end of the list
        set end of allFoundContent to text item 1 of blurb1

        set AppleScript's text item delimiters to astid

    end repeat

    -- from here you have three possibilities:
    -- 1. return the list to next Automator action (uncomment the next line):

    -- return allFoundContent


    -- 2. concatenate the list with a delimiter you like (here return & "------" & return)
    -- and give it to your preferred text editor from this point (uncomment the next lines):

    -- set AppleScript's text item delimiters to return & "------" & return
    -- tell application "TextEdit"
    --     make new document with properties {text: allFoundContent as text}
    -- end tell
    -- set AppleScript's text item delimiters to astid


    -- 3. concatenate the list with a delimiter you like (here return & "------" & return)
    -- and give it to the next workflow step, maybe a BBEdit action waiting for a string? (uncomment the next lines):

    -- set AppleScript's text item delimiters to return & "------" & return
    -- set returnString to allFoundContent as text
    -- set AppleScript's text item delimiters to astid
    -- return returnString


    -- Next decision (for choice 1 or 2):
    -- What do you want to give to next Automator action?

    -- you can pass your input (the given URLs) (uncomment next line):
    -- return input

    -- or your result list (uncomment next line):
    -- return allFoundContent
end run