private void start ( final WebDriver webDriver , final boolean isResuming ) { try { Validate . validState ( isStopped , "The crawler is already running." ) ; this . webDriver = Validate . notNull ( webDriver , "The webdriver cannot be null." ) ; // If the crawl delay strategy is set to adaptive, we check if the browser supports the // Navigation Timing API or not. However HtmlUnit requires a page to be loaded first // before executing JavaScript, so we load a blank page. if ( webDriver instanceof HtmlUnitDriver && config . getCrawlDelayStrategy ( ) . equals ( CrawlDelayStrategy . ADAPTIVE ) ) { webDriver . get ( WebClient . ABOUT_BLANK ) ; } if ( ! isResuming ) { crawlFrontier = new CrawlFrontier ( config ) ; } cookieStore = new BasicCookieStore ( ) ; httpClient = HttpClientBuilder . create ( ) . setDefaultCookieStore ( cookieStore ) . useSystemProperties ( ) . build ( ) ; crawlDelayMechanism = createCrawlDelayMechanism ( ) ; isStopped = false ; run ( ) ; } finally { HttpClientUtils . closeQuietly ( httpClient ) ; if ( this . webDriver != null ) { this . webDriver . quit ( ) ; } isStopping = false ; isStopped = true ; } }
Performs initialization and runs the crawler .