Skip to content

Instantly share code, notes, and snippets.

@EricLondon
Created March 21, 2012 15:45
Show Gist options
  • Save EricLondon/2148743 to your computer and use it in GitHub Desktop.
Save EricLondon/2148743 to your computer and use it in GitHub Desktop.
ruby screen shot
#!/usr/bin/env ruby
require 'selenium-webdriver'
require 'uri'
website_url = ARGV[0]
if website_url.empty?
puts "Website Argument Required.\n"
exit()
end
uri = URI::parse(website_url)
uri_host = uri.host
uri_path = uri.path
uri_filename = uri.host + uri.path
uri_filename = uri_filename.gsub('/', '_')
# Chrome
driver = Selenium::WebDriver.for :chrome
driver.get website_url
driver.save_screenshot("./" + uri_filename + ".png")
driver.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment