Registry / http-networking / drissionpage

drissionpage

JSON →
library4.1.1.4pypypi✓ verified 86d ago

DrissionPage is a Python-based web automation tool that efficiently combines browser control functionalities (similar to Playwright or Selenium) with high-performance data packet handling (akin to Requests). It provides a unified and user-friendly API for tasks like web scraping, automated testing, and general web interaction, allowing seamless transitions between full browser and headless HTTP modes. The library is actively maintained, currently at version 4.1.1.2, and aims for a balance of power, elegance, and ease of use, with a development cadence that includes frequent updates and feature enhancements.

pip install drissionpage
INSTALL
IMPORT
SIG · DRISSIONPAGE
D
drissionpage
http-networkingpythonv4.1.1.4
Install
3.9s avg
Import
1086ms
Disk
40MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 1.149s · 41.4MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 3.9s · import 1.023s · 42MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChromiumPage
from DrissionPage import ChromiumPage
from drissionpage.dp import ChromiumPage
The primary browser control class, directly available from the top-level package since v4.x. Older documentation or examples might show nested imports.
WebPage
from DrissionPage import WebPage
from DrissionPage import MixPage
Used for efficient request-only mode, introduced in v3.0 as a replacement for Selenium dependencies. `MixPage` was the predecessor for combined modes prior to v3.0.
SessionPage
from DrissionPage import SessionPage
from DrissionPage.dp import SessionPage
Used for efficient request-only mode, similar to WebPage, also directly available from the top-level package. Prefer WebPage for newer code.

This quickstart demonstrates how to initialize a `ChromiumPage` instance, navigate to a URL, extract the page title and an element's text, and then close the browser. It showcases the core browser automation capabilities.

from DrissionPage import ChromiumPage # Initialize a browser page (Chromium is default) page = ChromiumPage() # Navigate to a website page.get('https://www.example.com') # Print the title of the page print(f"Page Title: {page.title}") # Find an element by CSS selector and get its text element = page.ele('css:h1') if element: print(f"H1 Text: {element.text}") # Close the browser page.quit()
Debug
Known issues
breakingVersion 3.0 introduced significant architectural changes, reducing reliance on Selenium and introducing the `WebPage` class. Code written for pre-3.0 `MixPage` or direct Selenium integration may break.
fix
Review the official documentation for v3.0+ and migrate to `WebPage` for request mode or `ChromiumPage` for browser mode. Familiarize yourself with the new element interaction APIs.
affects: <3.0
gotchaWhen using DrissionPage in multi-threaded environments, direct use of `Browser` objects across threads can lead to `AttributeError: 'Browser' object has no attribute '_driver'` or other unexpected behavior due to non-thread-safe internal states.
fix
Each thread should create and manage its own independent `ChromiumPage` or `WebPage` instance to ensure thread safety. Do not share a single `Browser` or `ChromiumPage` object across multiple threads.
affects: All versions
gotchaElement not found errors (`DrissionPage.errors.ElementNotFoundError`) are common, especially with dynamic content or incorrect locators. This can be due to the page not loading completely, elements not being present yet, or incorrect CSS/XPath selectors.
fix
Utilize DrissionPage's built-in waiting mechanisms (e.g., `page.wait.ele_loaded()`, implicit/explicit waits) before attempting to interact with elements. Double-check your CSS selectors or XPath expressions for accuracy.
affects: All versions
gotchaOccasional timeout errors during page loading or `get()` requests can occur, particularly with unstable networks or heavily guarded websites.
fix
Increase the default timeout values using `page.set.timeouts()` or pass `timeout` arguments to specific methods like `page.get()`. Implement retry logic for network-dependent operations. Consider using a proxy if network stability is an issue.
affects: All versions
gotchaOpening multiple browser profiles simultaneously requires specific configuration and careful management, and may not behave as expected if not handled correctly.
fix
Consult the official DrissionPage documentation on managing browser profiles and multiple tabs/windows. Each profile often requires its own `ChromiumOptions` and `ChromiumPage` instance.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'Browser' object has no attribute '_driver'
Attempting to use a `Browser` or `ChromiumPage` object across multiple threads without proper isolation.
fix
Ensure each thread initializes its own `ChromiumPage` instance. Browser objects are not thread-safe.
DrissionPage.errors.ElementNotFoundError: 没有找到元素。
The specified element could not be found on the page within the default timeout. This often happens if the element is dynamic, not yet loaded, or the locator is incorrect.
fix
Verify your locator (CSS, XPath, etc.) and add explicit waits for the element to appear or be interactable (e.g., `page.wait.ele_loaded('css:.my-element')`).
TimeoutError: timeout
The browser or a specific operation (like `page.get()` or an element interaction) exceeded its allotted time before completing, possibly due to slow network, heavy page content, or anti-bot measures.
fix
Increase the timeout for the operation or the page object (e.g., `page.set.timeouts(page_load_timeout=30)`). Implement retry logic for unreliable operations.
Upgrade
Version history
4.1.1.4latest on PyPI · released May 27, 2026
Audit
Dependencies
Chromium-based browseroptionalRequired for browser automation features. The `[chromium]` extra handles driver management.
Agent activity
183 hits · last 30 days
node
168
Amazon
1
Perplexity
1
OpenAI (training)
1
Resources
drissionpage — pip install drissionpage · libregistry