Class PlaywrightFetcher
java.lang.Object
com.norconex.crawler.core.fetch.AbstractFetcher<PlaywrightFetcherConfig>
com.norconex.crawler.web.fetch.impl.playwright.PlaywrightFetcher
- All Implemented Interfaces:
Configurable<PlaywrightFetcherConfig>,EventListener<Event>,Fetcher,EventListener,Consumer<Event>
Uses Microsoft Playwright for browser-based crawling. Playwright drives real browsers (Chromium, Firefox, WebKit) across Windows, macOS, and Linux without requiring an external WebDriver binary — browser binaries are downloaded automatically by Playwright on first use.
Key advantages over WebDriverFetcher
- No external driver binary needed.
- HTTP response headers (including status codes) are captured natively via Playwright's response interception — no proxy sniffer is required.
- Supports three cross-platform engines: Chromium, Firefox, and WebKit.
Thread safety
Playwright is not thread-safe. Each crawl thread gets its own
Playwright and Browser instance managed via
ThreadLocal. All instances are tracked for clean shutdown.
Supported HTTP method
This fetcher only supports HTTP GET method.
HTTP Headers
HTTP response headers (including the real status code and reason phrase)
are captured via Playwright's page.onResponse() listener and
stored in the document metadata.
- Since:
- 4.0.0
- See Also:
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptRequest(@NonNull FetchRequest req) Optional method for subclasses to override when in need for additional acceptance logic beyond reference filters (which this abstract class provides).protected booleanbooleanfetch(FetchRequest req) protected voidInvoked once per fetcher when the crawler ends.protected voidInvoked once per fetcher instance, when the crawler starts.inthashCode()toString()Methods inherited from class com.norconex.crawler.core.fetch.AbstractFetcher
accept, accept
-
Constructor Details
-
PlaywrightFetcher
public PlaywrightFetcher()
-
-
Method Details
-
fetcherStartup
Description copied from class:AbstractFetcherInvoked once per fetcher instance, when the crawler starts. Default implementation does nothing.- Overrides:
fetcherStartupin classAbstractFetcher<PlaywrightFetcherConfig>- Parameters:
c- crawler
-
fetcherShutdown
Description copied from class:AbstractFetcherInvoked once per fetcher when the crawler ends. Default implementation does nothing.- Overrides:
fetcherShutdownin classAbstractFetcher<PlaywrightFetcherConfig>- Parameters:
c- crawler
-
acceptRequest
Description copied from class:AbstractFetcherOptional method for subclasses to override when in need for additional acceptance logic beyond reference filters (which this abstract class provides). This method is only invoked if there are no reference filters configured on this class, or all of them accepts the request document. Default implementation does nothing (always returntrue).- Overrides:
acceptRequestin classAbstractFetcher<PlaywrightFetcherConfig>- Parameters:
req- the fetch request to evaluate (nevernull)- Returns:
trueif accepted
-
fetch
- Throws:
FetchException
-
equals
- Overrides:
equalsin classAbstractFetcher<PlaywrightFetcherConfig>
-
canEqual
- Overrides:
canEqualin classAbstractFetcher<PlaywrightFetcherConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractFetcher<PlaywrightFetcherConfig>
-
toString
- Overrides:
toStringin classAbstractFetcher<PlaywrightFetcherConfig>
-
getConfiguration
-