Search in sources :

Example 1 with CollectorPipeline

use of us.codecraft.webmagic.pipeline.CollectorPipeline in project webmagic by code4craft.

the class Spider method getAll.

/**
     * Download urls synchronizing.
     *
     * @param urls urls
     * @return list downloaded
     */
public <T> List<T> getAll(Collection<String> urls) {
    destroyWhenExit = false;
    spawnUrl = false;
    startRequests.clear();
    for (Request request : UrlUtils.convertToRequests(urls)) {
        addRequest(request);
    }
    CollectorPipeline collectorPipeline = getCollectorPipeline();
    pipelines.add(collectorPipeline);
    run();
    spawnUrl = true;
    destroyWhenExit = true;
    return collectorPipeline.getCollected();
}
Also used : ResultItemsCollectorPipeline(us.codecraft.webmagic.pipeline.ResultItemsCollectorPipeline) CollectorPipeline(us.codecraft.webmagic.pipeline.CollectorPipeline)

Aggregations

CollectorPipeline (us.codecraft.webmagic.pipeline.CollectorPipeline)1 ResultItemsCollectorPipeline (us.codecraft.webmagic.pipeline.ResultItemsCollectorPipeline)1