Skip to main content

Overview

Scrapling’s parsing system is built on the Selector class, which provides a powerful and intuitive API for navigating and extracting data from HTML and XML documents. It’s powered by lxml for high performance.

Selectors

CSS, XPath, and flexible find methods

Navigation

Tree traversal and element relationships

Extraction

Text, attributes, and structured data

Selector Class

Creating Selectors

Configuration Options

Selection Methods

CSS Selectors

The most intuitive way to select elements:

XPath Selectors

For more complex queries:

Find Methods

Python-style element searching:

Find by Text

Search elements by their text content:

Find by Regex

Search using regular expressions:

Find Similar Elements

Find elements with similar structure (inspired by AutoScraper):

Data Extraction

Text Extraction

Attribute Extraction

HTML Extraction

JSON Extraction

Tree Navigation

Parent and Ancestors

Children and Descendants

Siblings

Selectors Container

The Selectors class is a list of Selector objects with additional methods:

Basic Operations

Extraction Methods

Filter and Transform

TextHandler

All text extracted by Scrapling is wrapped in TextHandler, which extends Python’s str with additional methods:

Basic String Operations

Cleaning

Regular Expressions

Conversion

AttributesHandler

Element attributes are wrapped in AttributesHandler, a dictionary-like object:

Advanced Features

Adaptive Element Relocation

Scrapling can save element signatures and relocate them even after page structure changes:

URL Joining

Element Properties

Performance Tips

Use Specific Selectors

Cache Results

Use Direct Methods

Error Handling

Next Steps

Sessions

Learn about session management

API Reference

Complete Selector API documentation

Examples

Real-world parsing examples