Interface PageEventHandlers
-
- All Implemented Interfaces:
public interface PageEventHandlersThe central interface for managing all event handlers triggered at various stages of a webpage's lifecycle.
PageEventHandlersorganizes events into three distinct groups:LoadEventHandlers - Events during the loading and parsing stage
BrowseEventHandlers - Events during the interactive browsing stage
CrawlEventHandlers - Events in the browser stage (before and after loading)
1. browser.onWillLoad 2. load.onNormalize 3. load.onWillLoad 4. load.onWillFetch 5. browse.onWillLaunchBrowser 6. browse.onBrowserLaunched 7. browse.onWillFetch 8. browse.onWillNavigate 9. browse.onNavigated 10. browse.onWillInteract 11. browse.onWillCheckDocumentState 12. browse.onDocumentFullyLoaded 13. browse.onWillScroll 14. browse.onDidScroll 15. browse.onDocumentSteady <-- Best for custom RPA actions 16. browse.onWillComputeFeature 17. browse.onFeatureComputed 18. browse.onDidInteract 19. browse.onWillStopTab 20. browse.onTabStopped 21. browse.onFetched 22. load.onFetched 23. load.onWillParse 24. load.onWillParseHTMLDocument 25. load.onHTMLDocumentParsed <-- Best for data extraction 26. load.onParsed 27. load.onLoaded 28. browser.onLoadedval handlers = DefaultPageEventHandlers() handlers.loadEventHandlers.onLoaded.addLast { page -> println("Loaded: ${page.url}") } val link = ListenableHyperlink(url, args = "-parse", eventHandlers = handlers) session.submit(link)val options = session.options("-parse") options.eventHandlers.browseEventHandlers.onDocumentSteady.addLast { page, driver -> driver.click("#button") } session.load(url, options)handlers.le.onLoaded.addLast { page -> } // loadEventHandlers handlers.be.onDocumentSteady.addLast { page, driver -> } // browseEventHandlers handlers.ce.onWillLoad.addLast { url -> url } // crawlEventHandlersDefaultPageEventHandlers- Standard implementation with default behaviorsAbstractPageEventHandlers- Base class for custom implementations
-
-
Method Summary
Modifier and Type Method Description abstract PageEventHandlerschain(PageEventHandlers other)Chains another page event handler to the tail of this one. abstract LoadEventHandlersgetLoadEventHandlers()Event handlers during the loading stage. abstract UnitsetLoadEventHandlers(LoadEventHandlers loadEventHandlers)Event handlers during the loading stage. abstract BrowseEventHandlersgetBrowseEventHandlers()Event handlers during the browsing stage. abstract UnitsetBrowseEventHandlers(BrowseEventHandlers browseEventHandlers)Event handlers during the browsing stage. abstract CrawlEventHandlersgetCrawlEventHandlers()Event handlers during the browser stage. abstract UnitsetCrawlEventHandlers(CrawlEventHandlers crawlEventHandlers)Event handlers during the browser stage. LoadEventHandlersgetLe()UnitsetLe(LoadEventHandlers le)BrowseEventHandlersgetBe()UnitsetBe(BrowseEventHandlers be)CrawlEventHandlersgetCe()UnitsetCe(CrawlEventHandlers ce)-
-
Method Detail
-
chain
abstract PageEventHandlers chain(PageEventHandlers other)
Chains another page event handler to the tail of this one.
All handler groups (load, browse, browser) are chained together. Chained handlers execute in order: this handler's callbacks first, then the other handler's callbacks.
val baseHandlers = DefaultPageEventHandlers() val customHandlers = DefaultPageEventHandlers() customHandlers.le.onLoaded.addLast { page -> println("Custom") } baseHandlers.chain(customHandlers) // Custom handler runs after base- Parameters:
other- The page event handlers to chain- Returns:
This handler instance for fluent chaining
-
getLoadEventHandlers
abstract LoadEventHandlers getLoadEventHandlers()
Event handlers during the loading stage.
Manages URL normalization, fetching, and document parsing.
-
setLoadEventHandlers
abstract Unit setLoadEventHandlers(LoadEventHandlers loadEventHandlers)
Event handlers during the loading stage.
Manages URL normalization, fetching, and document parsing.
-
getBrowseEventHandlers
abstract BrowseEventHandlers getBrowseEventHandlers()
Event handlers during the browsing stage.
Controls browser automation: navigation, scrolling, and custom RPA actions.
-
setBrowseEventHandlers
abstract Unit setBrowseEventHandlers(BrowseEventHandlers browseEventHandlers)
Event handlers during the browsing stage.
Controls browser automation: navigation, scrolling, and custom RPA actions.
-
getCrawlEventHandlers
abstract CrawlEventHandlers getCrawlEventHandlers()
Event handlers during the browser stage.
Wraps around load/browse phases for URL filtering and result handling.
-
setCrawlEventHandlers
abstract Unit setCrawlEventHandlers(CrawlEventHandlers crawlEventHandlers)
Event handlers during the browser stage.
Wraps around load/browse phases for URL filtering and result handling.
-
getLe
LoadEventHandlers getLe()
-
setLe
Unit setLe(LoadEventHandlers le)
-
getBe
BrowseEventHandlers getBe()
-
setBe
Unit setBe(BrowseEventHandlers be)
-
getCe
CrawlEventHandlers getCe()
-
setCe
Unit setCe(CrawlEventHandlers ce)
-
-
-
-