【问题标题】:How do I ignore an error message when using Automator?使用 Automator 时如何忽略错误消息?
【发布时间】:2014-09-11 06:55:02
【问题描述】:

我不是一个很好的程序员(根本不是),所以当我发现 Apple 的自动化工具时我非常兴奋。我使用 Extract URL> Get Specified URL > Get Text From Webpage > Extract Data > New Text Document 制作了一个非常粗糙的网络爬虫。但是,当 Automator 启动“从网页获取文本”过程时,这些 URL 会抛出错误消息。我知道我可以编写一些苹果脚本来解决这个问题,但是我很难实现它。

多个线程都暗示了一条try语句,例如:

 try
   --do what ever
 on error
   --continue with code
 end

问题在于如何编写“从页面获取文本”和“出错,继续代码”

有人可以帮忙吗?

【问题讨论】:

  • 您需要在其中放置一个用于测试有效 URL 的 applescript 操作。然后,on 错误将结束流程。

标签: applescript automator


【解决方案1】:

这里有一个简单的方法来获取网页的源代码并使用applescript中的shell脚本将其放入文件中:

do shell script " curl 'http://www.google.com' | cat >> '/users/compName/desktop/test.txt'"

你可以用它做很多事情,但它是一个简单的开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多