Tuesday, July 2, 2024

macos – Can I exploit Applescript to have Safari save a selected web page’s contents as supply?

Create an automator doc. Whereas testing, make it a workflow. As soon as you have bought it working the best way you want, you may make an software or no matter is most helpful.

Add two actions, each from the Web class:

  1. Get specified URLs
  2. Obtain URLs

With the primary motion, click on the develop triangle and if there’s a default URL in there, choose it and click on Take away after which Add your particular URL.

With the second motion, click on the The place dropdown and select a vacation spot. Click on ‘different’ to decide on an arbitrary location. It is likely to be worthwhile to have an unique folder specified as then you would simply run different actions on the ‘contents’ of the folder (see under).

Then click on ‘Run’ to check the workflow. It ought to obtain the html for the web page (however not the entire ancillary information) and put it aside within the specified location. If it already exists, it would save a further copy.

That is in all probability the best methodology to obtain an internet web page and would not require that Safari truly open the web page. You can additionally use applescript or you would use a command-line instrument like wget or curl and run it from the terminal.

Replace:

To make this into an app quite than a workflow, it is in all probability best to easily create a brand new app after which add the actions the identical approach that the workflow was created. Sadly, the file > convert to… menu command would not appear very efficient.

As to renaming the ensuing file, sadly the obtain urls motion would not appear to work as it would because it doesn’t present a outcome (ie a reference to the saved html).

You possibly can add a workaround although. Right here is one which makes use of the saved file (so it’s important to obtain the file so you may then ‘select’ it) after which renames that — observe which you could then take away/trash that preliminary file as you solely want it lengthy sufficient so as to add the entry to the motion. I exploit the ‘add date or time’ choice within the ‘rename finder objects’ motion as a result of it would not require person interplay however you may undergo the assorted choices and select the very best in your want.

  1. Get specified finder objects
    This makes use of add to specify the file so you will need to have a file within the obtain location with the proper title after which select it (eg ‘text-mode-web-browsers.html’). That is the title that the two-step obtain would generate based mostly in your provided url. Run it once more with the precise url to get the proper file title for that url. Observe, you do not want the precise file, simply the precise file title, so you would additionally simply stick a random textual content file there and provides it the identical title after which trash it.

  2. Rename finder objects: add date or time
    You possibly can select your renaming choices for this motion however
    the date/time one is straightforward to work with. Observe that some rename choices appear to operate solely in a workflow.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles