我写了一些苹果脚本来在早上叫醒我(here),它工作得很好,但是,我想添加一些功能。我希望脚本访问 this网页,并告诉我当前的温度。下面是上述网站上的温度元素。
<span id="rapidtemp" class="pwsrt" pwsid="IWESTERN183" pwsunit="metric" pwsvariable="tempf" english="°F" metric="°C" value="71.8">
<span class="nobr"> <span class="b">22.1</span> °C</span>
</span>
我想知道如何在 applescript 方面定义变量,如本网站上所述的温度。
我想知道该怎么做的另一件事是,当我上床 sleep 时运行这个脚本,所以它会等到 06:00,然后运行。
任何帮助将不胜感激。谢谢。
-迈克尔
最佳答案
你可以尝试这样的事情:
set myUrl to "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=-31.953005,115.857468"
set myTemp to text 2 thru -2 of (do shell script "curl " & quoted form of myUrl & " | grep 'span id=\"rapidtemp\"' | grep -Eo '\"[0-9]+\\.?[0-9]*\"'")
您可以使用 launchd 来安排这些事件。 Lingon会帮助你的。
关于html - Applescript 警报在特定时间运行并说出温度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20402648/