当前位置: 首页>>代码示例>>Java>>正文


Java Request.putExtra方法代码示例

本文整理汇总了Java中us.codecraft.webmagic.Request.putExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Request.putExtra方法的具体用法?Java Request.putExtra怎么用?Java Request.putExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在us.codecraft.webmagic.Request的用法示例。


在下文中一共展示了Request.putExtra方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: download

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
@Override
public Page download(Request request, Task task) {
	String html = null;
	try {
		html = casperjs.gatherHtml(new cn.nest.spider.entity.commons.Request(request.getUrl(), true));
	} catch(IOException e) {
		request.putExtra("EXCEPTION", e);
           onError(request);
           return null;
	}
	Page page = new Page().setRawText(html);
	page.setRequest(request);
	page.setUrl(new PlainText(request.getUrl()));
	onSuccess(request);
	return page;
}
 
开发者ID:TransientBuckwheat,项目名称:nest-spider,代码行数:17,代码来源:CasperjsDownloader.java

示例2: download

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
@Override
public Page download(Request request, Task task) {
    String html = null;
    Site site = null;
    if (task != null) {
        site = task.getSite();
    }
    try {
        html = casperjs.gatherHtml(new com.gs.spider.model.commons.Request(request.getUrl(), true));
    } catch (Exception e) {
        if (site.getCycleRetryTimes() > 0) {
            return addToCycleRetry(request, site);
        }
        request.putExtra("EXCEPTION", e);
        onError(request);
        return null;
    }
    Page page = new Page();
    page.setRawText(html);
    page.setUrl(new PlainText(request.getUrl()));
    page.setRequest(request);
    onSuccess(request);
    return page;
}
 
开发者ID:gsh199449,项目名称:spider,代码行数:25,代码来源:CasperjsDownloader.java

示例3: test

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
@Ignore("environment depended")
 @Test
 public void test() {
     Task task = new Task() {
         @Override
         public String getUUID() {
             return "1";
         }

         @Override
         public Site getSite() {
             return null;
         }

@Override
public void cron(String expr) {
}
     };
     Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/");
     request.putExtra("1","2");
     redisScheduler.push(request, task);
     Request poll = redisScheduler.poll(task);
     System.out.println(poll);

 }
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:26,代码来源:RedisSchedulerTest.java

示例4: test

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
@Ignore("environment depended")
@Test
public void test() {
    Task task = new Task() {
        @Override
        public String getUUID() {
            return "1";
        }

        @Override
        public Site getSite() {
            return null;
        }
    };
    Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/");
    request.putExtra("1","2");
    redisScheduler.push(request, task);
    Request poll = redisScheduler.poll(task);
    assertThat(poll).isEqualTo(request);

}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:22,代码来源:RedisSchedulerTest.java

示例5: writeExceptionLog

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
private void writeExceptionLog(Exception e, Request request) {
    if (staticValue.isCommonsSpiderDebug()) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        e.printStackTrace(printWriter);
        request.putExtra("EXCEPTION", stringWriter.toString());
    } else {
        request.putExtra("EXCEPTION", e.getMessage());
    }
}
 
开发者ID:bruceq,项目名称:Gather-Platform,代码行数:11,代码来源:ContentLengthLimitHttpClientDownloader.java

示例6: handleResponse

import us.codecraft.webmagic.Request; //导入方法依赖的package包/类
@Override
protected Page handleResponse(Request request, String charset, HttpResponse httpResponse, Task task)
		throws IOException {
	Page page = null;
	try {
		page = super.handleResponse(request, charset, httpResponse, task);
	} catch(IllegalArgumentException e) {
		LOG.warn("响应处理异常, url:{}, 由于 {}", request.getUrl(), e.getLocalizedMessage());
		request.putExtra("EXCEPTION", e);
		onError(request);
		throw e;
	}
	return page;
}
 
开发者ID:TransientBuckwheat,项目名称:nest-spider,代码行数:15,代码来源:ContentDownloader.java


注:本文中的us.codecraft.webmagic.Request.putExtra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。