Getting a link from a safari window
Getting a link from a safari window
Hi,
Using UI Scripting (with a lot of help from UI Browser) I've been able to identify specific links on a Safari page and click the links to open the linked page.
It would really help my script if I could get the link's URL first. This script will be visiting hundreds of pages, but if I can't determine if it's visited the URL already, it would be 1000s of pages.
I've looked at the source and the URLs are generated by Java script or something, so their text does not actually appear in the source.
Here's an illustration of what I'd like to do, with the part that doesn't work commented out.
What I can do instead is click the link, read the URL from the window as it's opening and if it's one that's been visited then bale, but that's not terribly efficient.
set pageLinks to {}
activate application "Safari"
tell application "System Events"
tell process "Safari"
tell window 1
tell group 3
tell scroll area 1
tell UI element 1
repeat
try
set thisLink to static text 1 of UI element 1 of group x
set x to x + 1
--if text item 2 of linkURL is not in visitedLinks then
set the end of pageLinks to thisLink
--end if
on error
exit repeat
end try
end repeat
end tell
end tell
end tell
end tell
end tell
end tell
Any suggestions?
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden