Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Search on Webside, copy a line and extract information from the line to put it on a variable

Hi I'm an air traffic controller on Ivao and I have a question



I wanted to write a script that fills information that I get from the web, into a numbers sheet.



The problem is, that I am very new to applescript, so I have some ideas of how to do this...



The goal is that the script "go's" to the website http://wx.ivao.aero/metar.php, than searches for the line that contains LOWW


LOWW 271350Z 14013KT CAVOK 28/15 Q1016 NOSIG


Something like this should be copped then.


Afterwards it should extract the 5 numbers that are written in front of the KT (14013)


These 5 numbers have to be split in to 140 and 13 and saved on to 2 variables


Finally these numbers should be send to "Numbers" where they should be then put into 2 cells



Sounds easy right?😀 (or maybe it is easy but I'm to dumb😉 )



I would appreciate any Ideas...


Ben

MacBook Pro with Retina display, OS X Yosemite (10.10.5)

Posted on Aug 27, 2015 7:29 AM

Reply
Question marked as Best reply

Posted on Aug 28, 2015 2:56 PM

Hello


You may try something like this.



_main() on _main() do shell script "curl -s 'http://wx.ivao.aero/metar.php' | perl -lne 'print qq($1 $2) if /^LOWW \\S+ (...)(..)KT/'" set rr to result's words repeat with r in rr set r's contents to 0 + r end repeat set {a, b} to rr tell application "Numbers" tell document 1's sheet 1's table 1 set cell "A2"'s value to a set cell "B2"'s value to b end tell end tell end _main



Good luck,

H

17 replies

Search on Webside, copy a line and extract information from the line to put it on a variable

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.