All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.xbynet.crawler.Processor Maven / Gradle / Ivy

The newest version!
package com.github.xbynet.crawler;

import java.io.Closeable;
import java.io.IOException;

import com.github.xbynet.crawler.http.FileDownloader;

/**
 *爬虫页面处理器,撰写爬虫时需要扩展此类
 */
public abstract class Processor implements Closeable{
	private FileDownloader fileDownloader=null;
	private Spider spider=null;
	
	public abstract void process(Response resp);
	
	public boolean download(Request req,String savePath){
		return fileDownloader.download(req, savePath);
	}
	public boolean download(String url,String savePath){
		Request req=new Request(url);
		return fileDownloader.download(req, savePath);
	}
	public FileDownloader getFileDownloader() {
		return fileDownloader;
	}

	public void setFileDownloader(FileDownloader fileDownloader) {
		this.fileDownloader = fileDownloader;
	}
	@Override
	public void close()throws IOException{
		
	}

	public Spider getSpider() {
		return spider;
	}

	public void setSpider(Spider spider) {
		this.spider = spider;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy