Class AbstractBrowser
-
- All Implemented Interfaces:
-
ai.platon.pulsar.common.event.EventEmitter,ai.platon.pulsar.skeleton.crawl.fetch.driver.Browser,java.lang.AutoCloseable
public abstract class AbstractBrowser extends AbstractEventEmitter<BrowserEvents> implements Browser, AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAbstractBrowser.Companion
-
Field Summary
Fields Modifier and Type Field Description private final IntegerinstanceIdprivate final StringuserAgentprivate StringuserAgentOverrideprivate final NavigateHistorynavigateHistoryprivate final Map<String, WebDriver>driversprivate final Map<String, Object>dataprivate final BooleanisConnectedprivate final BooleanisIdleprivate final BooleanisPermanentprivate final BooleanisActiveprivate final BooleanisClosedprivate final StringreadableStateprivate final BooleanisGUIprivate final DurationidleTimeoutprivate final BrowserIdidprivate final BrowserSettingssettingsprivate final BooleancanConnectprivate Function1<Throwable, Unit>eventExceptionHandlerprivate final Map<BrowserEvents, List<Function<Object>>>listenerspublic final static AbstractBrowser.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description AbstractBrowser(BrowserId id, BrowserSettings settings)
-
Method Summary
Modifier and Type Method Description IntegergetInstanceId()The browser instance id StringgetUserAgent()The user agent. final StringgetUserAgentOverride()final UnitsetUserAgentOverride(String userAgentOverride)NavigateHistorygetNavigateHistory()The navigation history. Map<String, WebDriver>getDrivers()The created drivers by this browser. Map<String, Object>getData()The associated data. BooleanisConnected()Check if this browser is open. BooleanisIdle()Check if this browser is idle. BooleanisPermanent()Check if this browser is permanent. BooleanisActive()Check if this browser is active. BooleanisClosed()Check if this browser is closed. StringgetReadableState()The status of this browser. final BooleanisGUI()final DurationgetIdleTimeout()BrowserIdgetId()The unique browser id BrowserSettingsgetSettings()The browser settings. abstract UnitrecoverUnmanagedPages()List<WebDriver>listDrivers()List all drivers, each driver is associated with a Chrome tab. AbstractWebDriverfindDriver(String url)Find the first driver by url. WebDriverfindDriver(Regex urlRegex)Find the first driver by url regex. List<WebDriver>findDrivers(Regex urlRegex)Find drivers by url regex. UnitdestroyDriver(WebDriver driver)Destroy the web driver, close the associated browser tabs. UnitdestroyForcibly()Destroy the browser forcibly, kill the associated browser processes, release all allocated resources, regardless of whether the browser is closed or not. UnitclearCookies()Clear all cookies. final UnitonInitialize()final UnitonWillNavigate(NavigateEntry entry)Unitclose()Unitmaintain()-
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.Browser
getCanConnect, newDriver, newDriver -
Methods inherited from class ai.platon.pulsar.common.event.AbstractEventEmitter
count, emit, emit, emit, emit, emit1, emit1, emit1, emit1, getEventExceptionHandler, getListeners, hasListeners, listeners, listeners, off, off, off, off, off, off1, off1, off1, off1, off1, on, on, on, on, on1, on1, on1, on1, once, once, once, once1, once1, once1, setEventExceptionHandler -
Methods inherited from class ai.platon.pulsar.common.event.EventEmitter
hasNormalListeners, hasSuspendListeners, normalListeners, normalListeners, suspendListeners, suspendListeners -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AbstractBrowser
AbstractBrowser(BrowserId id, BrowserSettings settings)
-
-
Method Detail
-
getInstanceId
Integer getInstanceId()
The browser instance id
-
getUserAgent
String getUserAgent()
The user agent. A user agent is a string that a browser sends to each website you visit. It's created when the browser first connected to the remote browser.
-
getUserAgentOverride
final String getUserAgentOverride()
-
setUserAgentOverride
final Unit setUserAgentOverride(String userAgentOverride)
-
getNavigateHistory
NavigateHistory getNavigateHistory()
The navigation history.
-
getDrivers
Map<String, WebDriver> getDrivers()
The created drivers by this browser.
-
isConnected
Boolean isConnected()
Check if this browser is open.
-
isPermanent
Boolean isPermanent()
Check if this browser is permanent.
If a browser is permanent:
it will not be closed when the browser is idle
the user data will be kept after the browser is closed
-
getReadableState
String getReadableState()
The status of this browser.
-
getIdleTimeout
final Duration getIdleTimeout()
-
getSettings
BrowserSettings getSettings()
The browser settings.
-
recoverUnmanagedPages
abstract Unit recoverUnmanagedPages()
-
listDrivers
List<WebDriver> listDrivers()
List all drivers, each driver is associated with a Chrome tab.
-
findDriver
AbstractWebDriver findDriver(String url)
Find the first driver by url.
-
findDriver
WebDriver findDriver(Regex urlRegex)
Find the first driver by url regex.
-
findDrivers
List<WebDriver> findDrivers(Regex urlRegex)
Find drivers by url regex.
-
destroyDriver
Unit destroyDriver(WebDriver driver)
Destroy the web driver, close the associated browser tabs.
-
destroyForcibly
Unit destroyForcibly()
Destroy the browser forcibly, kill the associated browser processes, release all allocated resources, regardless of whether the browser is closed or not.
-
clearCookies
Unit clearCookies()
Clear all cookies. Notice: even if we clear all cookies, the website still has some technology to track a session.
-
onInitialize
final Unit onInitialize()
-
onWillNavigate
final Unit onWillNavigate(NavigateEntry entry)
-
-
-
-