Open yangjinde opened 10 months ago
启动时,想将某个参数传到Processor中,但是发现根本获取不到,这个是什么原因?代码如下: `Request request = new Request("https:/www.xxxx.xxxx/xxx"); request.setRequestBody(HttpRequestBody.json("{'id':1}","utf-8"));
Spider.create(douyinProcessor).thread(1) .addPipeline(douyinPipeline) .setDownloader(douyinDownloader) .addRequest(request) .runAsync();`
后面代码在Processor中获取,获取不到前面的id值 Request request = page.getRequest(); String paramJson = new String(request.getRequestBody().getBody());
Request request = page.getRequest(); String paramJson = new String(request.getRequestBody().getBody());
获取不到前面传的body里边的内容呢,body是空的,用了request.putExtra方式也传不了。
在douyinDownloader里处理错了?
douyinDownloader
可以换种方式 Spider.create( new douyinProcessor(id) ).thread(1) ....然后在 douyinProcessor 构造方法中读取id
启动时,想将某个参数传到Processor中,但是发现根本获取不到,这个是什么原因?代码如下: `Request request = new Request("https:/www.xxxx.xxxx/xxx"); request.setRequestBody(HttpRequestBody.json("{'id':1}","utf-8"));
后面代码在Processor中获取,获取不到前面的id值
Request request = page.getRequest(); String paramJson = new String(request.getRequestBody().getBody());
获取不到前面传的body里边的内容呢,body是空的,用了request.putExtra方式也传不了。