Screenshot the viewport with Ruby and Puppeteer

Install Puppeteer and Grover

npm i puppeteer
gem install grover

Take a screenshot of the viewport and save to file

require 'grover'

File.open("viewport.png", "wb") do |f|
  f.write(Grover.new('https://www.bbc.co.uk/news/business-63709754').to_png)
end

Find out how to change the size of the viewport with Ruby and Puppeteer.

We created Urlbox to make converting HTML to images easy

Learn more about our website screenshot API.