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?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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.
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.