use of us.codecraft.webmagic.pipeline.ConsolePipeline in project webmagic by code4craft.
the class Spider method initComponent.
protected void initComponent() {
if (downloader == null) {
this.downloader = new HttpClientDownloader();
}
if (pipelines.isEmpty()) {
pipelines.add(new ConsolePipeline());
}
downloader.setThread(threadNum);
if (threadPool == null || threadPool.isShutdown()) {
if (executorService != null && !executorService.isShutdown()) {
threadPool = new CountableThreadPool(threadNum, executorService);
} else {
threadPool = new CountableThreadPool(threadNum);
}
}
if (startRequests != null) {
for (Request request : startRequests) {
addRequest(request);
}
startRequests.clear();
}
startTime = new Date();
}
use of us.codecraft.webmagic.pipeline.ConsolePipeline in project webmagic by code4craft.
the class QuickStarter method main.
public static void main(String[] args) {
init();
String key = null;
key = readKey(key);
System.out.println("The demo started and will last 20 seconds...");
// Start spider
OOSpider.create(Site.me(), clazzMap.get(key)).addUrl(urlMap.get(key)).addPipeline(new MultiPagePipeline()).addPipeline(new ConsolePipeline()).runAsync();
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("The demo stopped!");
System.out.println("To more usage, try to customize your own Spider!");
System.exit(0);
}
Aggregations