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

68 posts tagged with "python"

View All Tags

Web Scraping with Playwright Series Part 3 - Storing Data

· 23 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.

Web Scraping with Playwright Series Part 3 - Storing Data

In Part 2, we talked about creating a web scraper with Playwright to extract data from the Nike website, which has dynamically loaded content.

In Part 3, we will focus on carefully analyzing the extracted data and ensuring it's properly cleaned to deal with potential issues like missing values, inconsistencies, and outliers. The cleaned data will then be stored in different formats such as CSV, databases, and S3 buckets to make it easier for future decision-making.

Without further ado, let’s get started!

Web Scraping with Playwright Series Part 2 - Building a Scraper

· 18 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.

Web Scraping with Playwright Series Part 2 - Building a Scraper

In Part 1, you learned about the basics of Playwright, environment setup, browser launching, and taking screenshots.

In Part 2, you’ll learn how to build a scraper from scratch. We'll cover how to locate and extract data, manage dynamically loaded content, utilize Playwright's network event feature, and improve the scraper's performance by blocking unnecessary resources.

Without further ado, let’s get started!

Web Scraping with Playwright Series Part 1 - Getting Started

· 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.

Web Scraping with Playwright Series Part 1 - Getting Started

Introducing the 4-Part Series on Web Scraping with Playwright! This comprehensive series will delve into web scraping using Playwright, a powerful and versatile tool for automating browser interactions.

By the end of this series, you'll have a solid understanding of web scraping with Playwright. You'll be able to build robust scrapers that can handle dynamic content, efficiently store data, and navigate through anti-scraping mechanisms.

In Part 1, you'll learn about the basics of Playwright, why it's useful, how to set up the environment, how to launch the browser using Playwright, and how to take screenshots.

Requests vs HTTPX in 2026: Measured Differences and Migration Gotchas

· 26 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Requests vs HTTPX in 2026: Measured Differences and Migration Gotchas

Updated 2026-09-17

Every timing on this page now comes from one local server run by the evidence packet on requests 2.34.2 and httpx 0.28.1. The earlier version's benchmark table, which quoted third-party posts and unsourced figures, is gone. New: connection counting, threads vs asyncio, HTTP/2 on the same server, what "retries" means in each library, the errors a migration hits, and what the httpx 1.0 pre-release does to 0.28 code.

requests and httpx make the same request with almost the same line of code. The differences that matter are elsewhere: whether a connection is reused, how you run 200 requests at once, which protocol you speak, what happens by default on a redirect or a slow server, and what "retry" means. This page measures each of those on one server, then lists what breaks when you move a requests codebase to httpx 0.28.

The short version, from the tables below (Apple Silicon laptop, loopback, Python 3.12.11; the ratios are the claim, not the seconds):

Caserequests 2.34.2httpx 0.28.1
300 sequential GETs, one Session / Client (plain HTTP)0.150 s, 1 connection0.126 s, 1 connection
300 sequential GETs, no Session / Client (plain HTTP)0.217 s, 300 connections3.090 s, 300 connections (an SSL context is built per call)
200 GETs with a 50 ms server delay, 20 threads0.543 s (32 connections; 20 with pool_maxsize=20)0.545 s, 20 connections
Same 200 GETs, AsyncClient + asyncio.gather, Semaphore(20)not available0.558 s, 20 connections
Same 200 GETs over TLS, no semaphore (httpx caps in-flight work at 100), HTTP/1.1 vs HTTP/2HTTP/1.1 only0.476 s, 200 connections vs 0.171 s, 1 connection
50 MiB download, streamed, peak RSS35 MiB44 MiB
Retries against a 503urllib3.Retry(status_forcelist=[503]): 4 requests sentHTTPTransport(retries=3): 1 request (retries cover connection failures only)

Pick requests when the code is synchronous, the targets speak HTTP/1.1, and you want the larger ecosystem (plugins, mocks, examples). Pick httpx when you are inside asyncio (or an async framework), when you want HTTP/2, or when you want timeouts on by default. On a single reused connection the two are within a third of each other, and the one case where requests came out ahead was the loopback streaming test; nothing here says one is "faster".

BeautifulSoup Cheat Sheet (bs4 4.15): Tested Snippets, Parsers, Traps

· 20 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

BeautifulSoup Cheat Sheet (bs4 4.15): Tested Snippets, Parsers, Traps

Updated 2026-09-17

Rewritten as a tested cheat sheet. Every snippet below was run by the example package against one fixture page on beautifulsoup4 4.15.0, and the output is copied from that run. The 2024 version had no captured output (only inline # Output: comments), used the text= argument that has warned since 4.11, passed from_encoding to a str (ignored), and called pd.read_html with a string that pandas 3 now treats as a filename; all corrected. New: parsers compared on broken markup, a CPU-time table with min/median/max columns and a note on how much such timings move under load, the 4.13–4.15 deprecations captured with a type-checked example, and the errors you will actually see.

pip install beautifulsoup4 lxml # html5lib, requests and pandas only for the sections that use them
from bs4 import BeautifulSoup
with open("fixtures/page.html", encoding="utf-8") as f:
PAGE = f.read()

soup = BeautifulSoup(PAGE, "html.parser") # from a str
print(soup.title.string, "|", soup.h1.get_text(" ", strip=True))
Ant Supply — catalogue | Products (3)

That is the whole idea: parse, find, read. The sheet below is the rest of it, every line run against the same fixture page (a small catalogue with a nav, three product cards, a table, a comment and a script).

The best Python HTTP clients

· 8 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

The best Python HTTP clients

Python has emerged as a dominant language due to its simplicity and versatility. One crucial aspect of web development and scraping is making HTTP requests, and Python offers a rich ecosystem of libraries tailored for this purpose.

This report delves into the best Python HTTP clients, exploring their unique features and use cases. From the ubiquitous Requests library, known for its simplicity and ease of use, to the modern and asynchronous HTTPX, which supports the latest protocols like HTTP/2 and WebSockets, there is a tool for every need. Additionally, libraries like aiohttp offer versatile async capabilities, making them ideal for real-time data scraping tasks.

For those requiring low-level control, urllib3 stands out with its robust and flexible features. On the other hand, Uplink provides a declarative approach to API interactions, while GRequests combines the simplicity of Requests with the power of Gevent's asynchronous capabilities. This report also highlights best practices for making HTTP requests and provides a comprehensive guide to efficient web scraping using HTTPX and ScrapingAnt. By understanding the strengths and weaknesses of each library, developers can make informed decisions and choose the best tool for their web scraping and development tasks.

Python Requests: Ignore SSL Certificate Errors, and the Right Way

· 15 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Python Requests: Ignore SSL Certificate Errors, and the Right Way

Updated 2026-09-16

Rewritten as a tested reference. Every call shown below was executed by the example package against a local HTTPS server with a self-signed certificate; the output blocks are what it printed (see "How the outputs were captured"). Four recipes from the 2024 version were wrong and are shown failing here: passing an ssl.SSLContext as verify=, REQUESTS_CA_BUNDLE="", "verify=False disables verification globally", and the "certificate pinning" example built on the same invalid verify= call.

You called requests.get() and got this:

requests.exceptions.SSLError: HTTPSConnectionPool(host='localhost', port=8443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1010)')))

The two-line way to make it go away:

import requests, urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
response = requests.get("https://localhost:8443/", verify=False)

And the one-line way to fix it instead of hiding it, when you have the server's certificate or your company's CA file:

response = requests.get("https://localhost:8443/", verify="certs/localhost.pem")

The rest of this page shows what each option does, with the real output, including the recipes you will find elsewhere that do nothing or crash in current requests.

How to read from MongoDB to Pandas

· 9 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

How to read from MongoDB to Pandas

The ability to efficiently read and manipulate data is crucial for effective data analysis and application development. MongoDB, a leading NoSQL database, is renowned for its flexibility and scalability, making it a popular choice for modern applications. However, to leverage the full potential of MongoDB data for analysis, it is essential to seamlessly integrate it with powerful data manipulation tools like Pandas in Python.

This comprehensive guide delves into the various methods of reading data from MongoDB into Pandas DataFrames, providing a detailed roadmap for developers and data analysts. We will explore the use of PyMongo, the official MongoDB driver for Python, which allows for straightforward interactions with MongoDB. Additionally, we will discuss PyMongoArrow, a tool designed for efficient data transfer between MongoDB and Pandas, offering significant performance improvements. For handling large datasets, we will cover chunking techniques and the use of MongoDB's Aggregation Framework to preprocess data before loading it into Pandas.

Guide to Scraping and Storing Data to MongoDB Using Python

· 15 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Guide to Scraping and Storing Data to MongoDB Using Python

Data is a critical asset, and the ability to efficiently extract and store it is a valuable skill. Web scraping, the process of extracting data from websites, is a fundamental technique for data scientists, analysts, and developers. Python, with its powerful libraries such as BeautifulSoup and Scrapy, provides a robust environment for web scraping. MongoDB, a NoSQL database, complements this process by offering a flexible and scalable solution for storing the scraped data. This comprehensive guide will walk you through the steps of scraping web data using Python and storing it in MongoDB, leveraging the capabilities of BeautifulSoup, Scrapy, and PyMongo. Understanding these tools is not only essential for data extraction but also for efficiently managing and analyzing large datasets. This guide is designed to be SEO-friendly and includes detailed explanations and code samples to help you seamlessly integrate web scraping and data storage into your projects. (source, source, source, source, source)

Guide to Cleaning Scraped Data and Storing it in PostgreSQL Using Python

· 15 min read
Oleg Kulyk
Co-Founder @ ScrapingAnt

Guide to Cleaning Scraped Data and Storing it in PostgreSQL Using Python

In today's data-driven world, the ability to efficiently clean and store data is paramount for any data scientist or developer. Scraped data, often messy and inconsistent, requires meticulous cleaning before it can be effectively used for analysis or storage. Python, with its robust libraries such as Pandas, NumPy, and BeautifulSoup4, offers a powerful toolkit for data cleaning. PostgreSQL, a highly efficient open-source database, is an ideal choice for storing this cleaned data. This research report provides a comprehensive guide on setting up a Python environment for data cleaning, connecting to a PostgreSQL database, and ensuring data integrity through various cleaning techniques. With detailed code samples and explanations, this guide is designed to be both practical and SEO-friendly, helping readers navigate the complexities of data preprocessing and storage with ease (Python Official Website, Anaconda, GeeksforGeeks).