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?

  • 3
    curl primarily downloads a HTML file, not sure you can call this a „visit“ (it doesn’t execute any JavaScript for instance). Which problem are you finally trying to solve here?
    – nohillside
    Feb 7, 2022 at 20:23
  • @nohillside maybe curl is not the right tool here, but I am looking for a way to input an url at the command line, then output a screenshot of the webpage at the given url
    – zmkm
    Feb 7, 2022 at 20:30
  • 2
    For complex headless interactions with websites you can consider using something like puppeteer. Basically it runs Chrome (without showing the window), you can wait for the page to load and take a screenshot (or do a number of any other actions).
    – GACy20
    Feb 8, 2022 at 9:15
  • Note that screenshots are often not useful for web pages that may require scrolling to see the entire page. Exporting ('printing') to PDF is usually better for a web page. You can then convert the PDF to another format such as PNG or JPEG, if required. Feb 10, 2022 at 0:01

3 Answers 3


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.

  • 2
    Compared to other current answers, this has the big advantage that it can run in the background
    – PLL
    Feb 8, 2022 at 19:22

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.

You must log in to answer this question.

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