Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

启动时,自定义参数放在Request后面接收不到 #1133

Open
yangjinde opened this issue Nov 7, 2023 · 2 comments
Open

启动时,自定义参数放在Request后面接收不到 #1133

yangjinde opened this issue Nov 7, 2023 · 2 comments

Comments

@yangjinde
Copy link

启动时,想将某个参数传到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());

获取不到前面传的body里边的内容呢,body是空的,用了request.putExtra方式也传不了。

@sutra
Copy link
Collaborator

sutra commented Nov 7, 2023

douyinDownloader里处理错了?

@sparrow-ez
Copy link

可以换种方式 Spider.create( new douyinProcessor(id) ).thread(1) ....然后在 douyinProcessor 构造方法中读取id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants