{"id":13819926,"url":"https://github.com/vitalie/webshot","last_synced_at":"2025-05-16T07:32:28.964Z","repository":{"id":55964527,"uuid":"9768568","full_name":"vitalie/webshot","owner":"vitalie","description":"Captures a web page as a screenshot.","archived":false,"fork":false,"pushed_at":"2023-12-30T04:21:46.000Z","size":49,"stargazers_count":213,"open_issues_count":19,"forks_count":68,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-17T21:59:18.528Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitalie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-04-30T10:07:23.000Z","updated_at":"2025-02-11T07:00:32.000Z","dependencies_parsed_at":"2024-05-28T19:28:06.145Z","dependency_job_id":"2bd8f0c2-4328-4118-a9bf-6ca8ed31a72a","html_url":"https://github.com/vitalie/webshot","commit_stats":{"total_commits":82,"total_committers":12,"mean_commits":6.833333333333333,"dds":"0.25609756097560976","last_synced_commit":"da00ab822a22b9b7a9bbf3eb7d1bcb756687fa73"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalie%2Fwebshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalie%2Fwebshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalie%2Fwebshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalie%2Fwebshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitalie","download_url":"https://codeload.github.com/vitalie/webshot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254488426,"owners_count":22079427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T08:00:55.002Z","updated_at":"2025-05-16T07:32:28.645Z","avatar_url":"https://github.com/vitalie.png","language":"Ruby","funding_links":[],"categories":["Happy Exploring 🤘","Ruby"],"sub_categories":[],"readme":"# Webshot\n\nCaptures a web page as a screenshot using Poltergeist, Capybara and PhantomJS.\n\n  - [![Build Status](https://travis-ci.org/vitalie/webshot.svg?branch=master)](https://travis-ci.org/vitalie/webshot)\n\n## Installation\n\nDownload and install [PhantomJS](http://phantomjs.org/releases.html) version 2.X,\nadd the directory containing the binary to your PATH.\n\nAdd the `webshot` gem to your Gemfile:\n\n    gem \"webshot\"\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install webshot\n\n## Usage\n\n```rb\n# Setup Capybara\nws = Webshot::Screenshot.instance\n\n# Capture Google's home page\nws.capture \"http://www.google.com/\", \"google.png\"\n\n# Customize thumbnail\nws.capture \"http://www.google.com/\", \"google.png\", width: 100, height: 90, quality: 85\n\n# Specify only width, height will be computed according to page's height\nws.capture \"http://www.google.com/\", \"google.png\", width: 1024\n\n# Specify an array of additional HTTP status codes to accept,\n# beyond normal success codes like 200 or 302\nws.capture \"http://www.google.com/foo\", \"google_404.png\", allowed_status_codes: [404]\n\n# Customize thumbnail generation (MiniMagick)\n# see: https://github.com/minimagick/minimagick\nws.capture(\"http://www.google.com/\", \"google.png\") do |magick|\n  magick.combine_options do |c|\n    c.thumbnail \"100x\"\n    c.background \"white\"\n    c.extent \"100x90\"\n    c.gravity \"north\"\n    c.quality 85\n  end\nend\n\n```\n\nYou can wait some time after visit page before capturing screenshot.\n\n```rb\n# Timeout in seconds\nws.capture 'http://www.google.com/', 'google.png', timeout: 2\n\n```\n\nYou can login before capturing screenshot.\n\n```rb\nws.start_session do\n  visit 'https://github.com/login'\n  fill_in 'Username or Email', :with =\u003e 'user@example.com'\n  fill_in 'Password', :with =\u003e 'password'\n  click_button 'Sign in'\nend.capture 'https://github.com/username/', 'github.png'\n\n```\n\n## Scaling\n\nIt's not recommended to start multiple PhantomJS concurrently.\nYou should serialize requests, treat the process as unreliable and\nmonitor it with daemontools, god, monit, etc.\n\nRecommended setup:\n\n     [S3] \u003c-- [CloudFront + 404 handler] \u003c-- User Request\n      ^\n      |\n    Worker \u003c--\u003e [Queue] \u003c-- App\n\n\nThe application triggers screenshot requests which are queued and\nthen processed by a background worker ([Resque](https://github.com/resque/resque), [Sidekiq](https://github.com/mperham/sidekiq), etc).\nThe worker uploads the images to S3 which are served through\nCloudFront. The CDN should be configured to serve a default\nimage (404 handler) with a low TTL to handle screenshot are not\nyet ready or couldn't be generated.\n\nNotes:\n  - sed 's/S3/Your file hosting service/g'\n  - sed 's/CloudFront/Your CDN service/g'\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalie%2Fwebshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitalie%2Fwebshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalie%2Fwebshot/lists"}