How do I Capture Website’s Screenshot Using Command Line

How do I Capture Website’s Screenshot Using Command Line.

I do know what you’re pondering: why hassle with the command line for screenshots after I can simply navigate to the web site by way of a browser and take a screenshot using Mac’s keyboard shortcut or a screenshot device?

Well, couple of causes actually.

Firstly, it’s genuinely pleasing and helpful to know. Secondly, using command strains permits for automation. You can duplicate instructions, compile them right into a script, and run it to batch seize screenshots of predetermined web sites or URLs.

To take a screenshot in your Mac using the command line, right here’s how to do it. Start by opening the Terminal app (duh!)

Next, you’ll want to regulate the next command to specify two key issues:

  1. your screenshot’s saved location and its filename, and
  2. the URL of the web site you need to seize.
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome 
  --headless 
  --screenshot=/path/to/screenshot/image.png 
  https://www.domain.com

Let’s stroll by way of an instance. If you need to seize a screenshot of apple.com, title it “apple.jpg“, and put it aside to a folder named “screenshots“, that is how your command would look:

/Applications/Google Chrome.app/Contents/MacOS/Google Chrome 
  --headless 
  --screenshot=/screenshots/apple.png 
  https://www.apple.com

And that is what the screenshot will appear like:

Standard apple.com screenshotStandard apple.com screenshot

If you want to customise the screenshot’s dimensions, you are able to do so by including the next parameter:

--window-size=WIDTH,HEIGHT 

For instance, to seize a screenshot of apple.com at a decision of 450×800, your command needs to be formatted as follows:

/Applications/Google Chrome.app/Contents/MacOS/Google Chrome 
  --headless 
  --window-size=450,800 
  --screenshot=/screenshots/apple.png 
  https://apple.com

And right here’s the ensuing image:

Custom-size apple.com screenshotCustom-size apple.com screenshot


Check out more article on – How-To tutorial and latest highlights on – Technical News
Exit mobile version