Overview
Scrapling provides powerful methods to extract data from HTML elements. Whether you need text content, HTML markup, attributes, or structured data, Scrapling has you covered.Basic Extraction
get()
Serialize an element to a string.getall()
Extract data from all matched elements.extract() and extract_first()
Aliases for backward compatibility with other scraping libraries.Text Extraction
text
Get the direct text content of an element.get_all_text()
Get all text from an element and its descendants.str
default:"\\n"
Strings will be concatenated using this separator
bool
default:"false"
If True, strings will be stripped before being concatenated
Tuple
default:"('script', 'style')"
A tuple of tag names to ignore when extracting text
bool
default:"true"
If enabled, elements with text-content that is empty or only whitespaces will be ignored
HTML Extraction
html_content
Get the inner HTML of an element.prettify()
Get a formatted, prettified version of the HTML.body
Get the raw body without processing.Attribute Extraction
attrib
Access element attributes.Element Access with []
Direct attribute access using bracket notation.Check Attribute Existence
Tag Information
tag
Get the tag name of an element.has_class()
Check if an element has a specific class.str
required
The class name to check for
Regex Extraction
Extract data using regular expressions.re()
Apply regex to element text and return all matches.str | Pattern[str]
required
Can be either a compiled regular expression or a string
bool
default:"true"
If enabled, character entity references are replaced by their corresponding character
bool
default:"false"
If enabled, ignores all whitespaces and consecutive spaces while matching
bool
default:"true"
If disabled, the function will ignore letter case while matching
re_first()
Apply regex and return the first match.Any
default:"None"
The default value to be returned if there is no match
JSON Extraction
Extract and parse JSON data.json()
Parse element content as JSON.URL Handling
urljoin()
Join relative URLs with the page’s base URL.str
required
The relative URL to join with the page’s URL