Re: advanced safari work....
Re: advanced safari work....
- Subject: Re: advanced safari work....
- From: LuKreme <email@hidden>
- Date: Thu, 29 Jul 2004 19:26:15 -0600
On 28 Jul 2004, at 14:05, Erik Ness wrote:
I want to develop a script that will allow me to scan a web page for
certain links, then make a variety of different choices based on what
links are there.
This works well with Safari and BBEdit (using BBEdit's grep search). Or
you can simply use shell tools to call grep and sed yourself.
--- TESTED SCRIPT
tell application "Safari"
set PageSource to the source of document 1 as string
end tell
tell application "BBEdit"
set TempWinID to ID of (make new text window with properties
{name:"Temp TWOP", soft wrap text:true, source language:"HTML", color
syntax:true}) --EOL
select insertion point after last line of window id TempWinID
set the selection of window id TempWinID to PageSource
find "href=\"(
http://[^\"]*)\"" searching in text 1 of window id
TempWinID options {search mode:grep, starting at top:true,
wraparound:false, backwards:false, case sensitive:false, match
words:false, extend selection:false} --EOL
set FirstURL to (grep substitution of "\\1")
display dialog "The First URL is " & FirstURL giving up after 10
end tell
--- END OF SCRIPT (watch the long lines marked with --EOL
--
It was intended that when Newspeak had been adopted once and for all
and Oldspeak forgotten, a heretical thought...should be literally
unthinkable, at least so far as thought is dependent on words.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.