Class WebDriverFetcher
- All Implemented Interfaces:
Configurable<WebDriverFetcherConfig>,EventListener<Event>,Fetcher,EventListener,Consumer<Event>
Uses Selenium WebDriver support for using native browsers to crawl documents. Useful for crawling JavaScript-driven websites.
Considerations
Relying on an external software to fetch pages can be slower and not as
scalable and may be less stable. Downloading of binaries and non-HTML file
format may not always be possible. The use of HttpClientFetcher
should be preferred whenever possible. Use at your own risk.
If it is important for each requests to be sharing the exact same browser
session, consider reducing the number of threads to 1 since
each thread has their own browser instance.
If you are using a Selenium grid and want to use multiple threads, make sure you configure Selenium max number of sessions per node to align with the number of threads you expect the crawler to use.
Supported HTTP method
This fetcher only supports HTTP GET method.
HTTP Headers
By default, web drivers do not expose HTTP headers from HTTP GET request. If you want to capture them, configure the "httpSniffer". A proxy service will be started to monitor HTTP traffic and store HTTP headers.
NOTE: Capturing headers with a proxy may not be supported by all Browsers/WebDriver implementations.
- Since:
- 3.0.0
-
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
-
WebDriverFetcher
public WebDriverFetcher()
-
-
Method Details
-
fetcherStartup
Description copied from class:AbstractFetcherInvoked once per fetcher instance, when the crawler starts. Default implementation does nothing.- Overrides:
fetcherStartupin classAbstractFetcher<WebDriverFetcherConfig>- Parameters:
c- crawler
-
fetcherShutdown
Description copied from class:AbstractFetcherInvoked once per fetcher when the crawler ends. Default implementation does nothing.- Overrides:
fetcherShutdownin classAbstractFetcher<WebDriverFetcherConfig>- 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<WebDriverFetcherConfig>- Parameters:
req- the fetch request to evaluate (nevernull)- Returns:
trueif accepted
-
fetch
- Throws:
FetchException
-
equals
- Overrides:
equalsin classAbstractFetcher<WebDriverFetcherConfig>
-
canEqual
- Overrides:
canEqualin classAbstractFetcher<WebDriverFetcherConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractFetcher<WebDriverFetcherConfig>
-
toString
- Overrides:
toStringin classAbstractFetcher<WebDriverFetcherConfig>
-
getConfiguration
-
getUserAgent
-