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