Write an AppleScript to create a web link on the desktop

Solution 1:

This script will do what you asked. It grabs the URL and the Name of the current Safari tab and creates a weblink file on the desktop. It uses the page's name to name the file. If you want help parsing a better option for the file name, just ask.

try -- will just silently quit if front window is not valid
tell application "Safari"
    set theURL to URL of current tab of window 1
    set theName to name of current tab of window 1
end tell

tell application "Finder"
    make new internet location file at desktop to ¬
        theURL with properties {name:theName}
end tell
end try