HeadlessBrowser class

A headless browser implementation for web scraping

Constructors

HeadlessBrowser.new({HeadlessBrowserConfig? config, ScrapingLogger? logger})
Creates a new HeadlessBrowser instance

Properties

config HeadlessBrowserConfig
Configuration for the headless browser
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCache() Future<void>
Clears the browser cache
clearCookies() Future<void>
Clears all cookies
click(String selector) Future<bool>
Clicks on an element matching the given selector
close() Future<void>
Closes the browser
dispose() Future<void>
Disposes the headless browser
executeScript(String script) Future
Executes JavaScript in the browser and returns the result
extractData(Map<String, String> selectors, {Map<String, String>? attributes}) Future<Map<String, dynamic>>
Extracts data from the page using CSS selectors
fetchHtml({required String url, Map<String, String>? headers}) Future<String>
Fetches HTML content from a URL
getCookies(String url) Future<List<Map<String, String>>>
Gets all cookies for the current page
getHtml() Future<String>
Gets the HTML content of the current page
getPageSource() Future<String>
Gets the current page source
initialize() Future<void>
Initializes the headless browser
launch(HeadlessBrowserConfig config) Future<HeadlessBrowser>
Launches the browser with the given configuration
Navigates to the specified URL
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setCookies(String url, List<Map<String, String>> cookies) Future<void>
Sets cookies for the current page
setProxy(Proxy proxy) Future<void>
Sets a proxy for the browser to use
takeScreenshot() Future<Uint8List?>
Takes a screenshot of the current page
toString() String
A string representation of this object.
inherited
waitForDomContentLoaded({int timeoutMillis = 30000}) Future<bool>
Waits for the DOM content to be loaded
waitForElement(String selector, {int timeoutMillis = 10000}) Future<bool>
Waits for an element to be present in the DOM
waitForNetworkIdle({int timeoutMillis = 30000, int idleTimeMs = 500}) Future<bool>
Waits for the network to be idle

Operators

operator ==(Object other) bool
The equality operator.
inherited