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 BooleanisActiveprivate final StringuserAgentprivate StringuserAgentOverrideprivate final NavigateHistorynavigateHistoryprivate final Map<String, WebDriver>driversprivate final Map<String, Object>dataprivate final BooleanisIdleprivate final BooleanisPermanentprivate final BooleanisGUIprivate final DurationidleTimeoutprivate final BrowserIdidprivate final BrowserSettingsbrowserSettingsprivate Function1<Throwable, Unit>eventExceptionHandlerprivate final Map<BrowserEvents, List<Function<Object>>>listenerspublic final static AbstractBrowser.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description AbstractBrowser(BrowserId id, BrowserSettings browserSettings)
-
Method Summary
Modifier and Type Method Description BooleanisActive()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. BooleanisIdle()Check if this browser is idle. BooleanisPermanent()Check if this browser is permanent. final BooleanisGUI()final DurationgetIdleTimeout()BrowserIdgetId()The unique browser id final BrowserSettingsgetBrowserSettings()List<WebDriver>listDrivers()List all drivers, each driver is associated with a Chrome tab. WebDriverfindDriver(String url)Find a driver by url. WebDriverfindDrivers(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.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.skeleton.crawl.fetch.driver.Browser
newDriver, newDriver -
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 browserSettings)
-
-
Method Detail
-
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.
-
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
-
getIdleTimeout
final Duration getIdleTimeout()
-
getBrowserSettings
final BrowserSettings getBrowserSettings()
-
listDrivers
List<WebDriver> listDrivers()
List all drivers, each driver is associated with a Chrome tab.
-
findDriver
WebDriver findDriver(String url)
Find a driver by url.
-
findDrivers
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)
-
-
-
-