public FetchResult fetch(Task task, FetchResult result) throws Exception {
synchronized (site) {
if (site.fetcher == null){
PageFetcherImpl fetcher = new PageFetcherImpl();
SpiderConfig config = new SpiderConfig();
if (task.site.getCharset() != null && task.site.getCharset().trim().length() > 0)
config.setCharset(task.site.getCharset());
if (task.site.getUserAgent() != null && task.site.getUserAgent().trim().length() > 0)
config.setUserAgentString(task.site.getUserAgent());
if (task.site.getIncludeHttps() != null && task.site.getIncludeHttps().trim().length() > 0)
config.setIncludeHttpsPages("1".equals(task.site.getIncludeHttps()) || "true".equals(task.site.getIncludeHttps()));
String sdelay = task.site.getReqDelay();
if (sdelay == null || sdelay.trim().length() == 0)
sdelay = "200";
int delay = CommonUtil.toSeconds(sdelay).intValue()*1000;
if (delay < 0)
delay = 200;
config.setPolitenessDelay(delay);
fetcher.setConfig(config);
fetcher.init(site);
site.fetcher = fetcher;
}