John Smith John Smith - 1 year ago 99
AppleScript Question

Applescript Alarm Run at Specific Time and Say Temperature

I've written some applescript to wake me up in the mornings (here), and it works fine, however, I want to add some functionality. I want the script to access this webpage, and tell me the current temperature. Now below is the element for the temperature on the above website.

<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>&nbsp;°C</span>

I would like to know how I would define a variable on the applescript side of things, as the temperature stated on this website.

The other thing I wanted to know how to do, is how I could, say run this script when I got to bed, so it waits until 06:00, and then runs.

Any help would be greatly appreciated. Thanks.


Answer Source

You can try something like this:

set myUrl to ",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]*\"'")

You can use launchd to schedule these events. Lingon will help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download