Recommended Free Tools
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
After PhantomJS reports that a page loaded successfully, use page.evaluate() to remove or hide a verified, site-specific banner element, then call page.render(). There is no universal cookie-banner selector, and removing the element only changes the screenshot: it does not record consent. PhantomJS development is suspended, so treat this as a legacy maintenance technique rather than a foundation for a new capture pipeline.
Remove the banner before rendering
PhantomJS lets a script run JavaScript in the page context and render the page to an image. That makes a targeted DOM change possible between a successful page load and the screenshot. The important sequence is: open the page, verify that it loaded, find the actual banner element, remove or hide it, and only then render.
The selector in the example below is illustrative. Replace .cookie-consent with a selector verified on the site you are capturing. The code is derived from PhantomJS’s documented page.open, page.evaluate, and page.render APIs; it has not been tested against a live site.
Minimal PhantomJS example
var page = require('webpage').create();
page.open('https://example.com/', function(status) {
if (status !== 'success') {
console.log('Page failed to load');
phantom.exit();
return;
}
page.evaluate(function() {
var banner = document.querySelector('.cookie-consent');
if (banner && banner.parentNode) {
banner.parentNode.removeChild(banner);
}
});
page.render('page.png');
phantom.exit();
});
Run the script with the PhantomJS executable and save it as a JavaScript file, for example capture.js. The output path is relative to the script’s working directory unless you provide an absolute path. If the callback reports a status other than success, this example prints an error and exits without rendering.
Remove versus hide
Removing the element from its parent is appropriate when you want it absent from the captured DOM. Alternatively, leave the page structure intact and apply a narrowly targeted style:
page.evaluate(function() {
var banner = document.querySelector('.cookie-consent');
if (banner) {
banner.style.display = 'none';
}
});
Hiding is easier to reverse within the page, while removing changes the DOM structure. Either method can have side effects if the selected node contains unrelated content. Avoid broad selectors such as body or a generic page wrapper; verify that the selector identifies only the consent interface.
#1 Best Overall
Find and verify the right selector
Cookie interfaces are implemented differently from site to site. A class or ID seen on one website is not a reliable selector for another. Inspect the target page’s markup in a browser’s developer tools, identify the smallest element that contains the banner, and test that selector against the exact page variant your script captures.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Prefer a distinctive banner ID or class over a generic element name.
- Check that the selected node is the banner itself, not a parent containing navigation, page content, or other overlays.
- Account for site variants: localization, A/B tests, logged-in state, or a different consent platform can change the markup.
- If the selector returns no element, do not assume the banner is gone. It may use different markup or have appeared after the script ran.
For repeat captures, keep selectors configurable per site rather than treating one selector as universal. A selector that is too broad can create a misleadingly clean screenshot by deleting real page content.
Handle banners that appear after page load
A successful page.open callback indicates that the page’s load operation completed; it does not guarantee that every later application update has finished. A consent banner may be inserted asynchronously after that callback. In that case, the immediate query can run too early.
Add a deliberate delay or a site-specific readiness check before querying and rendering. Keep any delay limited to what the target site requires: waiting longer adds capture time and still does not prove that every delayed change has completed. PhantomJS’s load-completion callbacks do not guarantee completion of all later application activity.
Rank #2
For a robust legacy job, log whether the expected selector was found and distinguish that outcome from a successful page load. If the banner is absent, the site may not show it for that request, the consent state may already be stored, or the selector may no longer match. Those cases should not silently be treated as proof that the removal logic worked.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteControl the screenshot dimensions
Set page.viewportSize when you need a consistent browser viewport. Use clipRect when the output should cover a specific rectangle rather than the full rendered page. These capture settings do not locate or remove the banner; they control the rendered area after your DOM adjustment.
For example, a viewport can be set before opening the URL:
page.viewportSize = { width: 1280, height: 900 };
Use dimensions appropriate to your capture requirement. A banner outside a clipping rectangle may simply be excluded from the image even though it remains in the page; that is different from removing it from the DOM. If the goal is to inspect the page without consent UI, use a verified DOM operation rather than relying on cropping.
Visual cleanup is not consent
Removing or hiding an element changes what is visible in the screenshot. It does not necessarily tell the website that a visitor accepted or rejected cookies, save a consent preference, or prevent the site from creating the banner again.
PhantomJS’s deleteCookie(cookieName) operation is separate: it deletes matching cookies visible to the current URL. Deleting cookies is not a way to remove the banner. Because a site may store its consent state in a cookie, deleting that state can cause the site to show the prompt again. Do not use cookie deletion as a substitute for a targeted visual adjustment, and do not imply that a screenshot-only change expresses a user’s consent choice.
Common failures and practical fixes
| Symptom | Likely cause | What to check |
|---|---|---|
| The script reports a load failure and produces no image. | page.open did not report success. |
Keep the status check, record the requested URL and status, and investigate the page load rather than rendering an assumed-valid result. |
| The banner is still visible. | The selector did not match, or the banner was inserted after the evaluation ran. | Verify the selector on the target page and add a suitable wait or readiness check for delayed UI. |
| Other page content disappears. | The selector matched a parent or generic container that includes more than the banner. | Narrow the selector and verify the selected element before removing it. |
| The banner reappears on the next capture. | The DOM change applied only to that page instance, or the site recreated the element. | Run the adjustment for each capture and account for asynchronous re-creation; do not confuse hiding the element with saved consent. |
| A banner appears after cookies were deleted. | The site may use stored cookie state to remember consent, and deleting it can prompt again. | Keep cookie-state handling distinct from screenshot-only element removal. |
| The output excludes the banner but it remains in the page. | The clipping rectangle or viewport excluded it from the rendered area. | Check the capture geometry if you need a full-page view; use DOM removal when the requirement is to remove the overlay itself. |
Should you use PhantomJS for a new capture pipeline?
The PhantomJS project homepage states that development is suspended until further notice. That status is a material maintenance concern for a new production pipeline: a suspended project may not keep pace with changes in modern sites or browser behavior. The DOM technique above can still be useful when maintaining an existing PhantomJS script, but the available evidence does not establish current compatibility, performance, or a migration schedule for any particular site.
Rank #3
For an alternative, evaluate whether you need a locally controlled browser or a hosted capture service, how you will handle page-specific scripts and styles, and which screenshot options your workflow requires. PhantomJsCloud documents browser automation capabilities including style injection and screenshot options such as full-page capture and clipping. That establishes a feature category, not comparative quality, current partner terms, or pricing.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you need a hosted capture instead of maintaining a PhantomJS browser script, ScreenshotNeo is a website screenshot API and MCP server for developers. A GET request with a URL returns a PNG, JPEG, WebP, or PDF. Its cleanup steps can accept the cookie or consent banner as a visitor and remove 60-plus known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For a simple image capture, replace the sample URL with the page you need. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same endpoint can be called from Python or Node.js:
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}`);
These examples show the basic request; check the API documentation for output and capture parameters. The MCP server exposes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. ScreenshotNeo offers 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card required.
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.

