2

The following command will dump the dom for a web page using Google Chrome:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome  --headless --disable-gpu --dump-dom http://example.com

I'm wondering if something similar is possible for Safari.

I can do this with AppleScript but I'd prefer the solution for Safari to be "headless" (see --headless option in command above), so I think an AppleScript will not achieve what I'm looking for.

** UPDATE **

Selenium driver has a headless mode for other browsers. But it doesn't look like there is such a mode for safari: https://stackoverflow.com/a/58314435

0

1 Answer 1

1

I’m fairly confident Safari isn’t amenable to scraping, so use Chrome or Firefox for that on macOS if you need a browser to be scriptable.

However, swift and python are exceptionally good at this by calling code directly via NSURL or equivalent as well as using the NSURLSessiond daemon and working with the OS directly and not even needing Safari.

Of course you have to learn some new language and API/SDK for this to pay off. The pay off can be huge if you have a command line tool that does all the heavy lifting far more efficiently than Chrome or Safari can.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .