Safari scripting questions

I do not know how much os safari can be scripted. Here are some of my questions if anyone can help.

  1. Can applescript get the name of the current location (web page)?
  2. If I do a search in google. Is there a way to tell the number of links or items found on the first page?
  3. Is there a way to get the HMTL cde of an entire site?
    Thanks!
tell application "Safari" to {name, URL} of document 1
tell application "Safari" to do JavaScript "document.links.length" in document 1

Or, may be better for you:

set searchTerm to "<a class=l"
tell application "Safari" to set src to source of document 1
set AppleScript's text item delimiters to searchTerm
set src to src's text items
set AppleScript's text item delimiters to {""}
set numRealLinx to (count src) - 1

Yes, but it wouldn’t fit in this page. You better stick with one of the huge amount of available crawlers at MacUpdate or VersionTracker :wink: