AppleScript cURL 和解析 URL
我正在开发 Automator 工作流程,我将 URL 列表传递给“运行 Applescript”,我需要获取每个页面上的内容,连接并将其传递给 BBedit(或任何其他文本编辑器)。
on run {input, parameters}
tell application "BBEdit"
activate
set astid to AppleScript's text item delimiters
set startHere to "<tbody>"
set stopHere to "</tbody>"
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
set blurb2 to text item 1 of blurb1
set AppleScript's text item delimiters to astid
return blurb2
beep
end repeat
end tell
end run
当前代码只能正确获取第一个 URL 中的内容。有人能解决这个问题吗?
I am working on a Automator workflow, I am passing list of URLs to the "Run Applescript" and I need to fetch the contents of on each page, concatenate and pass it to a BBedit (or any other text editor).
on run {input, parameters}
tell application "BBEdit"
activate
set astid to AppleScript's text item delimiters
set startHere to "<tbody>"
set stopHere to "</tbody>"
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
set blurb2 to text item 1 of blurb1
set AppleScript's text item delimiters to astid
return blurb2
beep
end repeat
end tell
end run
The current code only properly gets only the contents from first URL. Can anybody fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个子例程可能正是您所需要的(如果您使用的是 Safari)...
调用它时使用:
我希望这会有所帮助!
This subroutine may be what you need (if you're using Safari)...
Call it using:
I hope this helps!
因为您处于
repeat with anItem in input
循环中,所以它会完成第一个项目的所有工作,并且return
退出循环,实际上是整个 Automator 操作。我认为您从未从脚本中听到过beep
;-)另一方面,我想知道为什么您希望 BBEdit 为您完成 cUrl 和排序工作。所有被调用的处理程序都不属于 BBEdit...
我认为您的处理程序应该如下所示:
问候,迈克尔/汉堡
Because you are inside the
repeat with anItem in input
loop it does all your work for the first item and thereturn
exits the loop and in fact the whole Automator action. I think you have never heard thebeep
from your script ;-)On the other side I'm wondering why you want BBEdit to do the cUrl and sort work for you. All called handlers don't belong to BBEdit...
I think your handler should look like this:
Greetings, Michael / Hamburg