Created
October 18, 2011 20:47
-
-
Save martinsson/1296674 to your computer and use it in GitHub Desktop.
Simple != Simple to use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BatchCrawler { | |
public BatchCrawler(Job job) { | |
this.job = job; | |
this.timeout = ConfigurationService.getInt(SCAN_TIMEOUT); | |
httpCrawler = new RetryingHttpCrawler(); | |
} | |
public CrawlResult crawl() { | |
CrawlResult crawlResult = new CrawlResult(); | |
for (Url url : job.getUrls()) { | |
Page page = httpCrawler.visit(url, timeout); | |
result.add(url, page.content()); | |
} | |
return crawlResult; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BatchCrawler(Job job, int timeout, Crawler crawler) { | |
this.job = job; | |
this.timeout = timeout; | |
this.crawler = crawler; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static retryingBatchCrawlerWithSystemConfig(Job job) { | |
int timeout = ConfigurationService.getInt(SCAN_TIMEOUT); | |
int[] retryintervals = ConfigurationService.getIntArray(RETRY_INTERVALS); | |
Crawler retryingHttpCrawler = new RetryingHttpCrawler(retryIntervals); | |
return new BatchCrawler(job, timeout, retryingHttpCrawler) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment