• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting a link from a safari window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting a link from a safari window


  • Subject: Getting a link from a safari window
  • From: "email@hidden" <email@hidden>
  • Date: Sat, 22 May 2010 14:03:59 -0700

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

  • Follow-Ups:
    • Re: Getting a link from a safari window
      • From: Axel Luttgens <email@hidden>
    • Re: Getting a link from a safari window
      • From: Tommy Bollman <email@hidden>
    • UI Scripting
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
  • Next by Date: UI Scripting
  • Previous by thread: Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
  • Next by thread: UI Scripting
  • Index(es):
    • Date
    • Thread