Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →To capture a webpage from Ruby, send its URL to a hosted screenshot API and save or use the returned image. The API’s renderer loads the page and takes the shot, so you do not need to run a browser in your Ruby app. This example uses html2img’s documented Ruby client; its requirements and option names apply to that provider, not to every screenshot API.
Capture a page with the html2img Ruby client
The html2img Ruby guide documents Ruby 3.1 or newer and an API key. Install the gem, store the key in a server-side environment variable, then call screenshot with the target URL and viewport dimensions:
As an Amazon Associate I earn from qualifying purchases.
-
Install the client:
gem install html2img. -
Set your API key in the environment as
HTML2IMG_API_KEY. Do not put the key in browser-side JavaScript or public source code.Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Save this as
screenshot.rband run it with Ruby:
require "html2img"
client = Html2img::Client.new(api_key: ENV.fetch("HTML2IMG_API_KEY"))
response = client.screenshot(
"https://example.com",
width: 1200,
height: 630
)
puts response.url
The documented response includes a URL and status information. This example prints the returned URL; check the provider’s current response documentation for the exact fields and how long a result remains available.
#1 Best Overall
See the html2img Ruby guide for the current client setup and options. The Ruby client README documents the response shape and request behavior. The code above illustrates the documented syntax; it has not been independently tested here.
Choose what the screenshot includes and when it is taken
Viewport, full page, or one element
-
widthandheightset the viewport dimensions. The README documents dimensions from 1 to 5000; the client validates recognized options locally. -
Use
fullpage: trueto capture the page’s full scroll length instead of only the visible viewport.PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Use
selectorto capture a particular page element rather than the whole viewport. Confirm the selector matches an element present on the rendered page.
Wait for dynamic content
Pages that populate after their initial load may need extra time before capture. The guide documents wait_for_selector and ms_delay. Prefer waiting for a known element that indicates the content is ready; a fixed delay is simpler but cannot tell whether loading finished early or is still in progress.
Hide overlays with injected CSS
CSS injection can hide a cookie banner, chat widget, or other overlay. A site’s own styles may override your rule, so the guide notes that adding !important can be necessary. Check the selector against the actual page; a rule that matches nothing will not remove the overlay.
Know what the remote renderer can access
A hosted screenshot API renders the page from its own environment. The html2img guide says captures are anonymous: if the requested route requires a login, the result will generally show what an unauthenticated visitor sees, such as the sign-in page. Do not assume private pages can be captured. Use an authenticated-capture feature only if the provider documents it and you have assessed how credentials are handled.
Resources referenced by the page must also be reachable by that remote renderer. The html2img README says localhost resources do not resolve from its renderer. A local development server or assets available only inside your network therefore will not be visible to it.
Handle long captures and failures
Synchronous request timing
The html2img README gives synchronous requests a 30-second budget. A page that takes longer may not return a completed screenshot through that path. For longer work, its documentation describes webhook delivery; handle the processing response and wait for the webhook before relying on a final result URL.
Rank #3
Common problems and fixes
-
Ruby version or gem setup error: confirm you are using Ruby 3.1 or newer and that the
html2imggem installed in the same Ruby environment that runs the script. -
Missing API key: check that
HTML2IMG_API_KEYis set in the process environment and is available to the Ruby process.ENV.fetchraises an error if the variable is absent.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
The screenshot shows a login page: the renderer is anonymous. A protected route will not become accessible merely because your local browser is signed in.
-
Images or scripts are missing: verify that the page’s referenced resources are publicly reachable from outside your development machine and network, rather than hosted only at
localhost.Rank #4
-
Content is missing because the capture ran too soon: wait for a reliable selector with
wait_for_selector, or usems_delaywhen a fixed wait is appropriate. -
An option is rejected or dimensions are invalid: confirm option spelling and limits in the provider’s current guide. Options and limits vary across APIs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
A long render does not complete synchronously: use the documented webhook workflow for work that may exceed the 30-second synchronous budget.
Hosted API or browser automation in Ruby?
A hosted API lets your Ruby code make an HTTP request while the provider operates the rendering environment. Browser automation, such as Puppeteer Ruby, gives your application more direct control but means your team must operate that browser stack. The available documentation establishes these different implementation responsibilities, not a general performance, reliability, or price winner. Choose based on whether you want a managed capture endpoint or control over the browser environment, and verify each provider’s access model, capture options, response format, and long-job handling.
Best Value
Or skip the browser setup
ScreenshotNeo is a screenshot API and MCP server for developers. One GET request returns an image or PDF. Its API removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. AI agents can take screenshots through its MCP server.
For example, save a WebP response to a file with cURL:
Free tools Windows power users keep installed
One-click scans. No signup required.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for authentication and response details. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, no card required.
FAQ
Can I capture a page behind a login?
With the documented html2img flow, captures are anonymous, so a protected page generally returns its unauthenticated view. A provider-specific authenticated-capture feature would need to be documented separately.
Does this example save the image directly to disk?
No. It prints the response URL. Use the provider’s current response documentation to retrieve or otherwise use the image from that URL.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




