How to Hide Cookie Banners in URL2PNG Screenshots
Hide a cookie banner in a URL2PNG screenshot by injecting a hosted CSS file with the documented custom_css_url option, then verify selectors, signing, timing, and cache behavior.
To hide a cookie banner in a URL2PNG screenshot, host a CSS file that targets the banner and pass its reachable URL as custom_css_url in the URL2PNG request. The selector must match the actual page markup; there is no universal cookie banner selector. If you use URL2PNG’s signed v6 request flow, include custom_css_url in the complete query string before calculating the request token.
This method changes what appears in the screenshot. It does not accept or reject cookies on the visitor’s behalf. Check the target site’s requirements before changing how consent controls appear.
1. Find the banner’s selector
Inspect the page in a browser, or inspect its HTML, and identify a selector specific to the consent panel. Common examples might be an ID, a class, or an attribute, but names vary by site. Avoid broad selectors such as footer or dialog unless you have confirmed that they identify only the banner.
For example, if inspection shows the banner has id="cookie-banner", target #cookie-banner. If it has class="cookie-consent", target .cookie-consent. The following are illustrative CSS selectors, not URL2PNG-provided selectors:
/* Replace these examples with selectors observed on the target site. */
#cookie-banner,
.cookie-banner,
.cookie-consent {
display: none !important;
}
Remove the selectors that do not match your page. A narrow selector reduces the chance that the stylesheet hides legitimate page content.
2. Host the stylesheet
Save the rule in a CSS file and make it available at a URL the screenshot service can fetch. The URL2PNG documentation demonstrates a remote stylesheet URL supplied using custom_css_url. Check that the file is publicly reachable by the capture service and that it returns the intended CSS. A stylesheet behind a login, restricted by IP, or blocked by a firewall will not be usable by the capture request.
3. Add custom_css_url to the URL2PNG request
URL2PNG’s v6 request format places the target URL and options in a query string. The documentation says the token is the MD5 hash of the entire query string plus the account secret. Add custom_css_url before computing the token; signing a different query string can make the request invalid. Encode the target URL and option values with your URL library so characters such as &, ?, and # do not corrupt the query.
The following is the request shape, not a complete signed URL: exact account-specific fields and token construction must follow URL2PNG’s current v6 quickstart.
https://www.url2png.com/v6/PATH_OR_ACCOUNT_FIELDS/?url=ENCODED_TARGET&custom_css_url=ENCODED_STYLESHEET_URL&token=TOKEN_FOR_THE_COMPLETE_QUERY
Do not put the account secret in browser-side JavaScript or other public client code. Generate signed requests on a server where the secret can remain private. Consult the URL2PNG Quickstart Guide for the complete account-specific request format and signing procedure.
4. Verify the result and request a fresh capture
- Confirm the CSS URL is reachable and contains the rule you intend to use.
- Confirm the selector matches the banner on the exact target URL and page state.
- Include the stylesheet option in the signed query string, if using signed v6 requests.
- Request a fresh capture while validating a CSS change. URL2PNG documents a default cache TTL of 2,592,000 seconds (30 days) and a
uniqueoption that can vary a request, for example with a timestamp. - Inspect the returned image. If the banner remains, diagnose selector matching, stylesheet loading, timing, and caching separately.
Configuration options that affect the capture
| Option | What it controls | When it helps |
|---|---|---|
custom_css_url |
Injects a hosted CSS file into the page. | The documented mechanism for applying custom visual styling such as hiding a known banner. |
viewport |
Capture dimensions. Documentation lists 1480x1037 as the default and a maximum of 5000x5000 in its PHP example. |
Use dimensions that make the banner and page layout easy to inspect. A different viewport can change responsive markup and which selector appears. |
fullpage=true |
Attempts to capture the full document canvas; viewport-only is the documented default. | Use when the page content extends below the initial viewport. It is not a banner detector. |
delay |
Waits a fixed number of seconds after document readiness and asset loading. | May help with content that appears after initial load. URL2PNG notes it is generally needed for cases such as Flash animations; it is not a guaranteed fix for every delayed consent banner. |
say_cheese=true |
Waits for a page to contain <div id='url2png-cheese'></div>. |
Useful only if you control or can modify the target page to expose that marker. It is not cookie-banner-specific. |
unique |
Varies the request to force a fresh screenshot; URL2PNG suggests using a timestamp. | Use during validation when cached output could hide a stylesheet or page-state change. |
These controls solve different problems. Full-page capture changes the captured area, delay and marker waiting affect when capture proceeds, and unique addresses freshness. None is documented as automatic cookie-banner detection.
Using URL2PNG through Cloudinary
Cloudinary documents a URL2PNG add-on integration whose URL form uses <Website URL>/url2png/<option=value>|.... That is a Cloudinary transformation path; do not assume its syntax is interchangeable with URL2PNG’s direct API query string. Follow the mechanics for the integration path you actually use and confirm how it passes the custom stylesheet option. See Cloudinary’s URL2PNG add-on documentation.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| The banner is still visible. | The selector does not match the current page markup, the CSS file did not load, or the result is cached. | Inspect the live DOM, verify stylesheet reachability, then vary unique to request a fresh image. |
| Other page content disappears. | The selector is too broad and matches more than the consent panel. | Use an ID or a more specific class/attribute selector confirmed on the target site. |
| The request is rejected after adding the CSS option. | The token was calculated for a query string that omitted the new option, or the query was encoded inconsistently. | Build and encode the complete parameter set first, then calculate the token according to the URL2PNG v6 instructions. |
| The CSS works in a browser but not in the screenshot. | The screenshot service cannot fetch the hosted file, or the actual target page differs by route, locale, or responsive state. | Check public reachability and inspect the exact page variant captured. |
| The banner appears only sometimes. | The site may render it conditionally or after a delay, or the screenshot may be served from cache. | Use a fresh request, confirm the banner’s rendered selector, and try a measured delay if it appears after load. Do not treat delay as a universal solution. |
| Cloudinary ignores a direct API-style option. | The add-on uses its own transformation URL syntax. | Use the Cloudinary integration’s documented option syntax and verify the generated request behavior. |
Performance, reliability, and cost considerations
A remote stylesheet adds a resource that must be available when the screenshot is rendered. Keep it small, stable, and reachable; if its host is unavailable or access-restricted, the intended visual change may not apply. The source documentation does not publish a benchmark for the added latency of a custom stylesheet, so measure your own capture workflow if timing matters.
Cache behavior matters when iterating: the documented default TTL is 30 days, so a screenshot may not reflect changed CSS until you request a fresh variant. Use unique only when you need freshness; varying every request can defeat useful caching. No topic-specific published statistic on banner hiding or its cost was found in the reviewed URL2PNG material. Review your URL2PNG account terms for applicable pricing and request limits.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. Its API can accept a URL in one GET request and return an image or PDF. For an API key, request examples, and options, see the ScreenshotNeo documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.
Sign up for ScreenshotNeo’s free 1,000 screenshots a month, with no card required.
FAQ
Can URL2PNG remove any cookie banner automatically?
The reviewed documentation describes CSS injection, not automatic cookie-banner detection. You need a selector that matches the site’s actual banner.
Does hiding the banner record consent?
No. CSS changes the rendered appearance in the screenshot; it does not itself accept cookies or store a consent choice.
Will full-page capture or a delay hide the banner?
Neither option is documented as a banner-hiding feature. Use CSS for the visual change; use capture timing and dimensions only when those are independently needed.
Why is a changed stylesheet not visible immediately?
URL2PNG documents caching and a default 30-day TTL. Request a fresh variant with unique while checking changes.


