DrissionPage

repository·master·Indexed 11 days ago

https://github.com/g1879/drissionpage

A high-performance Python library for web automation and scraping that serves as an alternative to Selenium. It eliminates the need for WebDriver management, simplifies iframe and multi-tab control, and supports Chromium-based browsers and Electron applications.

Tokens
841
Snippets
1
Records
4
Agent score
46%

What's inside DrissionPage

  1. DrissionPage core features and highlights

    master

    DrissionPage includes several built-in features designed to make automation more stable and easier to write:

    • Minimalist Syntax: Simplified element locating syntax.
    • Automatic Stability: Built-in waiting mechanisms and automatic retries to handle unstable network conditions.
    • Powerful Download Tool: Integrated download capabilities while operating the browser.
    • Persistent Browser Sessions: Allows reusing already opened browser instances for easier debugging instead of restarting every time.
    • Configuration Management: Supports using .ini files to save and automatically load common configurations.
    • Testing Ready: Supports the Page Object Model (POM) pattern for easy expansion and testing.
  2. Key advantages of DrissionPage over Selenium

    master

    DrissionPage uses a self-developed core that offers several advantages for web automation and scraping compared to Selenium:

    • No WebDriver required: You do not need to download specific drivers for different browser versions.
    • Higher Performance: Faster execution speeds.
    • Simplified iframe handling: You can search for elements across iframes without manually switching in and out; iframes are treated as regular elements.
    • Multi-tab support: You can operate on multiple tabs simultaneously without needing to switch focus.
    • Advanced Browser Interaction:
      • Directly read browser cache to save images without GUI clicks.
      • Capture full-page screenshots, including areas outside the viewport.
      • Handle shadow-root elements even when not in an open state.
    • Built-in Parsing: Uses lxml as the parsing engine for significantly faster processing.
  3. Install and run DrissionPage

    master

    DrissionPage is a Python-based web automation tool designed to be concise and powerful. It is an alternative to Selenium that does not rely on WebDriver.

    Requirements

    • Supported Systems: Windows, Linux, Mac
    • Python Version: 3.6 or higher
    • Supported Browsers: Chromium-based browsers (e.g., Chrome, Edge) and Electron applications.
  4. Use the DrissionPage CLI to configure paths and launch the browser

    master

    The DrissionPage CLI allows you to quickly set browser and user data paths, copy default configuration files to your current directory, or launch a browser instance with a specific port.

    Available Options:

    • -p, --set-browser-path <PATH>: Sets the path to the browser executable.
    • -u, --set-user-path <PATH>: Sets the path for user data.
    • -c, --configs-to-here: A flag that copies the default configuration files to your current working directory.
    • -l, --launch-browser <PORT>: Launches the browser.
      • Pass a port number (e.g., 9222) to launch on that port.
      • Pass 0 to use the values defined in your configuration files.
      • Defaults to -1 (no browser launch).
    # Example: Set browser path and launch on port 9222
    drissionpage --set-browser-path /path/to/chrome --launch-browser 9222
    
    # Example: Copy default configs to current directory
    drissionpage --configs-to-here
    
    # Example: Set user data path and launch using config values
    drissionpage --set-user-path ./my_user_data --launch-browser 0