Here are a couple of AppleScript solutions for dealing with webloc.
- Tell the browser to pop a save dialog where you give the webloc a name and save.
- An AppleScript droplet (application) where you drag and drop a .webloc onto the app icon and a scrollable dialog will appear with the .webloc URL. You can right-click on that displayed URL and choose open link.
The first script is copy/pasted from here into the open Script Editor, and then saved as a script, script bundle, or application. When you have a Safari browser open to a website that you wish to save as a .webloc, you run this script.
-- Save Webloc File as… v.1.0
-- Script by Lisa Thompson, lthompson.22@mac.com
-- <http://homepage.mac.com/lthompson.22/applescript/forcamino.html>
-- For use with Safari in Mac OS 10.5 or 10.6. Also works on Ventura 13.0.1.
-- Install at the path ~/Library/Scripts/Applications/Safari, where ~ represents the home folder,
-- creating any subfolders that don't already exist.
-- Saves the URL from the current Safari tab as a .webloc file, prompting for name and location
-- in a standard open/save dialog.
-- Source: http://forums.mozillazine.org/viewtopic.php?f=12&t=2030915&start=15
tell application "Safari"
set tURL to (URL of front document) as text
if (tURL = "") then
set alertMsg1 to "There is no Safari web page available."
display alert alertMsg1 message "" as informational buttons {"OK"} default button 1
return
end if
set tTitle to (name of front document) as text
set tTitle to my replaceChars(tTitle, ":", "-")
set tPrompt to "Save .webloc file as..."
set uFilePath to (choose file name with prompt tPrompt default name tTitle) as text
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set tFileName to (last text item of uFilePath)
set tParentPath to (((text items 1 through ((count text items of uFilePath) - 1) of uFilePath) as text) & ":")
set AppleScript's text item delimiters to oldDelim
tell application "Finder" to make new internet location file to tURL at tParentPath with properties {name:tFileName}
end tell
on replaceChars(srcText, oldChars, newChars)
if (srcText = "") or (oldChars = "") then return srcText
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to oldChars
set tList to (every text item of srcText)
set AppleScript's text item delimiters to newChars
set srcText to (tList as text)
set AppleScript's text item delimiters to oldDelim
return srcText
end replaceChars
The second script which is saved as an AppleScript application (droplet) to your Desktop and allows you to drag and drop a .webloc file onto it and it will display the URL as shown below:

The code for this is at How can I see the address of a website in… - Apple Community