I am aware curl on Mac lets you visit a site from the command line.
Is there a way to visit that site then take a screenshot and download it?
I am aware curl on Mac lets you visit a site from the command line.
Is there a way to visit that site then take a screenshot and download it?
You can use the open utility to open a URL in your default browser, along with the screencapture utility to take a screenshot. You may want to use the -T <seconds> option for the latter to give the browser time to download and render.
Example:
open https://duckduckgo.com && screencapture -T 10 screenshot.png
You might also want to check if your browser has a shell or Applescript API that allows capturing screenshots. You may be able get a more complete screenshot of the page with fewer extras, like the menu bar and window frame.
Note that you may need to give your terminal app permission to record the screen.
If you have Google Chrome, you can open it in headless mode. It also have a way to "print" page to pdf. Try:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --print-to-pdf http://www.google.com/
Taking full page screenshot as png is a bit more complex. Here's Medium article about it.
You could use AppleScript to choose which browser you want or just consume the url directly with the open command as opposed to using curl. From there, use screencapture to dump the window to a file. Assuming the page is simple, you won’t have to build delays into the script to let items finish rendering.