NEWScrapingAnt MCP for Claude Code, Cursor & Windsurf — try it free →
Skip to main content

266 posts tagged with "web scraping"

View All Tags

Selenium Cookies in Python: Set, Save and Validate Scraped Data

· 12 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Selenium Cookies in Python: Set, Save and Validate Scraped Data

Updated 2026-09-27

Replaced mixed-language API examples, cookie insertion on about:blank and untested session recipes with runnable extraction tests. The evidence includes Chrome and Firefox cookie restoration, incorrect-data cases, and a separate ScrapingAnt test that receives and resends synthetic cookies. The original URL and publication date are preserved.

To set a cookie in Selenium Python, first navigate to its target origin, then call driver.add_cookie() with a name/value dictionary. Navigate or refresh afterward so the next request uses it. To reuse a session, save the relevant cookies, restore them on the same origin in the new browser, and check the resulting data.

That last step matters. In our controlled catalog, every extraction returned HTTP 200 and four product rows. Restoring only the session cookie still selected member prices—but in USD when the intended dataset was EUR. A successful navigation, an authenticated-looking page and the expected row count all missed the error.

This guide shows the cookie operations, a complete runnable save/restore example, and the measured failures behind that distinction. The catalog and accounts are synthetic; the results demonstrate mechanisms, not production-site success rates.

Selenium Local Storage in Python: Set, Restore, Extract

· 11 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Selenium Local Storage in Python: Set, Restore, Extract

Updated 2026-09-27

Replaced broken advanced examples and unsupported performance claims with a runnable catalog experiment in Chrome and Firefox. The code, captures and result definitions distinguish changing storage from changing the data you extract.

Use Selenium Python's execute_script to access localStorage in the current document. Navigate to the intended origin first, pass keys and values as arguments, and include return when you need a value back in Python. If the application reads a preference at startup, set it before entering that application page or trigger its documented refresh afterward.

The last step matters for extraction. In our fixture, writing eu after the table loaded changed localStorage but left all four prices in USD. A wait that checked only the stored key would have accepted the wrong dataset. The examples below check storage, the application's request and the resulting records.

Playwright Local Storage: Set Before Load and Validate Data

· 10 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Playwright localStorage initialization and extracted data

Updated 2026-09-27

Replaced unsupported performance percentages and broken advanced recipes with runnable Chromium and Firefox experiments. The examples now distinguish startup state, current stored values and the records actually extracted.

To change localStorage on an already loaded origin, use page.evaluate(). If the application reads that value during startup, install an origin-guarded context.add_init_script() before navigation, or create the context with the required storage_state.

That timing matters when scraping. In our catalog fixture, setting the region to eu after the table had loaded changed the stored value but left four US-priced rows on screen. A reload produced the intended EUR records. A successful storage write alone did not validate the data.

Puppeteer Local Storage: Set, Save and Restore Before Load

· 12 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Puppeteer Local Storage: Set, Save and Restore Before Load

Updated 2026-09-27

Replaced broken advanced examples and unsupported performance claims with a tested Chrome packet covering startup timing, state restoration, origin errors and extracted records. See the captured results.

Use page.evaluate() to read or change localStorage in an already loaded Puppeteer page. To supply a value before the application's scripts run, install an origin-guarded page.evaluateOnNewDocument() callback before navigation. Pass values as arguments; a function executing in the page cannot implicitly use your Node.js variables or helpers.

Then check the data you meant to extract. Our catalog returned four rows with a captured HTTP 200 status in every extraction observation, yet 15 of the 36 observations contained the deliberately selected wrong dataset. A successful write to localStorage was not enough to update the page.

How to Set Cookies in Puppeteer

· 12 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

How to Set Cookies in Puppeteer

In the realm of web automation and testing, Puppeteer has emerged as a powerful tool for developers and QA engineers. One crucial aspect of web interactions is the management of cookies, which play a vital role in maintaining user sessions, personalizing experiences, and handling authentication. This comprehensive guide delves into the intricacies of setting cookies in Puppeteer using JavaScript, exploring various methods and best practices to enhance your web automation projects.

Cookies are small pieces of data stored by websites on a user's browser, serving as a memory for web applications. In Puppeteer, manipulating these cookies programmatically allows for sophisticated automation scenarios, from maintaining login states to testing complex user flows. As web applications become increasingly complex, the ability to effectively manage cookies in automated environments has become a critical skill for developers.

This article will explore the fundamental methods for setting cookies in Puppeteer, including the versatile page.setCookie() function and the context-wide context.addCookies() method. We'll also delve into advanced techniques for cookie persistence, handling secure and HttpOnly cookies, and managing cookie expiration and deletion. Additionally, we'll cover best practices and advanced techniques that will elevate your cookie management skills, ensuring your Puppeteer scripts are robust, secure, and efficient.

By mastering these techniques, developers can create more reliable and sophisticated web automation solutions, capable of handling complex authentication flows, maintaining long-running sessions, and accurately simulating user interactions across various web applications. Whether you're building automated testing suites, web scrapers, or complex browser-based tools, understanding the nuances of cookie management in Puppeteer is essential for success in modern web development landscapes.

As we explore these topics, we'll provide detailed code samples and explanations, ensuring that both beginners and experienced developers can enhance their Puppeteer skills and create more powerful, efficient, and secure web automation solutions.

Looking for Playwright? Check out our guide on How to Set Cookies in Playwright.

Avoid Detection with Puppeteer Stealth

· 7 min read
Satyam Tripathi
Satyam is a junior data engineer and seasoned blogger. He has created several top-ranked tutorials on different topics like web scraping, automation, and scraping tools. He is always open to working with new technologies in the market and sharing his knowledge.

Avoid Detection with Puppeteer Stealth

Puppeteer is a powerful Node.js library that provides a high-level API for controlling browsers through the DevTools Protocol. It is commonly used for testing, web scraping, and automating repetitive browser tasks. However, Puppeteer's default settings can trigger bot detection systems, especially in headless mode.

Playwright Stealth: 5 Libraries Tested Against Bot Detectors

· 13 min read
Satyam Tripathi
Satyam is a junior data engineer and seasoned blogger. He has created several top-ranked tutorials on different topics like web scraping, automation, and scraping tools. He is always open to working with new technologies in the market and sharing his knowledge.

Playwright Stealth: 5 Libraries Tested Against Bot Detectors

Updated 2026-09-22

Replaced the legacy Playwright 1.40 recipe and historical screenshots with five library integrations, plain-browser controls and dated BrowserScan/Sannysoft observations. A diagnostic result does not establish that a scraper is undetectable or will reach a protected target. The tested code, raw results and screenshots preserve both successful captures and excluded harness errors.

Which Playwright stealth library should you use? In this comparison, Patchright returned BrowserScan's Normal verdict when headed, while its headless user agent was flagged. Node's playwright-extra with the stealth plugin and the Firefox-based Camoufox returned Normal in both modes. Python playwright-stealth had no failed Sannysoft checks but still received BrowserScan's Navigator flag.

That difference is the useful result: changing a browser property, passing a diagnostic page and successfully retrieving your target are separate tests. Start with a reproducible control and keep the browser version, operating system and launch mode attached to every observation.

Playwright Cookies: Save State and Share Sessions with API Requests

· 12 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Playwright Cookies: Save State and Share Sessions with API Requests

Updated 2026-09-27

Replaced mixed sync/async recipes, manual Set-Cookie parsing and untested state assumptions with runnable Chromium and Firefox experiments. The new examples test context restoration, browser/API cookie sharing, missing local storage and duplicate requests against extracted catalog records. The original URL, banner and publication date are preserved.

To set cookies with Playwright Python, call context.add_cookies() with a list of cookie dictionaries. Supply url, or a suitable domain and path, and set the cookies before navigating when the first request needs them. Use context.storage_state() when the workflow also depends on supported browser storage beyond cookies.

Restoring the cookie does not necessarily restore the dataset. In our catalog, cookies-only restoration kept member pricing but selected USD instead of EUR. A browser-associated API request made the same mistake when it omitted a region parameter that the page normally reads from local storage.

This guide shows the working state handoff and the failures around it. The fixture is self-authored and synthetic; it demonstrates specific mechanisms, not the probability that a real website will accept a restored login.

Understanding the High Cost of Residential Proxies

· 12 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Understanding the High Cost of Residential Proxies

In the rapidly evolving landscape of internet technologies, residential proxies have emerged as a critical tool for businesses and researchers seeking to access geo-restricted content, conduct market research, and perform large-scale web scraping operations. However, the high cost associated with these services has become a significant point of discussion within the industry. This comprehensive report delves into the multifaceted factors contributing to the elevated prices of residential proxies and examines the complex market dynamics shaping this sector.

At the heart of the cost issue lies the scarcity of residential IP addresses. As the internet continues its exponential growth, the pool of available IPv4 addresses has become increasingly depleted (Harvard Business School). This scarcity has given rise to a second-hand market for IP addresses, driving up costs and creating new challenges for proxy providers (VMBlog).

Beyond the issue of scarcity, the operational complexities involved in maintaining a vast and distributed network of residential IPs contribute significantly to the high costs. Unlike datacenter proxies, residential proxies rely on a decentralized infrastructure that spans multiple geographic locations and involves real residential internet connections. This decentralized nature introduces additional challenges in terms of stability, management, and performance optimization (Infatica).

Ethical considerations and regulatory compliance also play a crucial role in the cost structure of residential proxy services. Reputable providers must navigate a complex landscape of legal requirements, including data protection laws like GDPR, while ensuring that their IP sources are ethically obtained with proper user consent (Geekflare).

This report will explore these factors in detail, providing insights into the technical aspects of residential proxy networks, the strategies employed by premium providers to differentiate their services, and the innovative solutions being developed to address the challenges in this field. We will also examine pricing models, performance metrics, and real-world use cases to provide a comprehensive understanding of the residential proxy market.

To illustrate the practical implementation of residential proxies, we will include code samples in popular programming languages such as Python and JavaScript, demonstrating how these tools can be effectively utilized in various scenarios. By the conclusion of this report, readers will have gained a thorough understanding of the factors driving the high costs of residential proxies and the complex market dynamics that shape this essential component of modern internet infrastructure.

Axios vs Fetch - A Comprehensive Comparison with Code Samples

· 10 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Axios vs Fetch - A Comprehensive Comparison with Code Samples

In the ever-evolving landscape of web development, making HTTP requests is a fundamental task for many applications. Two popular tools for handling these requests in JavaScript are Axios and Fetch. As developers, choosing the right tool for the job can significantly impact the efficiency and maintainability of our code. This comprehensive comparison aims to shed light on the key differences between Axios and Fetch, helping you make an informed decision for your next project.

Axios, a promise-based HTTP client for both browser and Node.js environments, has gained popularity due to its intuitive API and robust feature set. On the other hand, Fetch, a more recent addition to web browsers, provides a powerful and flexible low-level API for making HTTP requests. While both serve the same primary purpose, their approaches to syntax, error handling, and data processing differ significantly.

In this article, we'll delve into the nuances of Axios and Fetch, exploring their syntax, ease of use, error handling mechanisms, and JSON processing capabilities. We'll provide code samples and detailed explanations to illustrate the strengths and weaknesses of each approach. By the end of this comparison, you'll have a clear understanding of when to use Axios or Fetch in your projects, based on factors such as project requirements, browser support needs, and personal or team preferences.

As we navigate through this comparison, it's important to note that while Axios offers more built-in features and a simpler API, making it easier for many developers to use, Fetch provides greater flexibility as a low-level API. This flexibility, however, often comes at the cost of additional setup for common tasks. Let's dive into the details and explore how these differences manifest in real-world coding scenarios.