how can i download a webpage and extract some data from it

hi

i am very new to applescript.

i want to be able to get some information from a web page and display it in a window using applescript. any ideas how to do this?

thanks

:wink:

You can get the HTML code from a web page using some browsers (eg, IE’s “GetSource” command) or two well know tools: URL Access Scripting (“download” command) and shell’s curl. I like the last one method:

do shell script "curl [url=http://www.google.com/]http://www.google.com/"[/url]

Will return the HTML code for such page.
Then, you can extract the info you need using several ways. Eg, the title:

set HTMLText to (do shell script "curl [url=http://www.google.com/)]http://www.google.com/")[/url]
set theTitleStart to (offset of "<title>" in HTMLText) + 7
set theTitleEnd to (offset of "</title>" in HTMLText) - 1

set theTitle to text theTitleStart thru theTitleEnd of HTMLText

Then, depending of your GUI needs, you can use some tools or not.
For this title, I will choose a standard “display dialog” command:

display dialog theTitle