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

发送post请求时返回400 #23

Open
2637977081 opened this issue Oct 31, 2019 · 1 comment
Open

发送post请求时返回400 #23

2637977081 opened this issue Oct 31, 2019 · 1 comment

Comments

@2637977081
Copy link

2637977081 commented Oct 31, 2019

你好,我在测试用例中没有找到post请求的模板调用

这是我的调用代码
` Map<String,String> dataMap = new HashMap<>();
dataMap.put("category","**");
dataMap.put("currentPage","1");
dataMap.put("pageSize","30");

    Map<String,String> headerMap = new HashMap<>();
    headerMap.put("Accept-Encoding","gzip");
    headerMap.put("Content-Type","application/json;charset=UTF-8");
    headerMap.put("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");

    XxlCrawler xxlCrawler = new XxlCrawler.Builder()
            .setUrls(url)
            .setAllowSpread(false)
            .setIfPost(true)
            .setHeaderMap(headerMap)
            .setParamMap(dataMap)
            .setPageParser(new PageParser() {
                @Override
                public void parse(Document html, Element pageVoElement, Object pageVo) {
                    XxlJobLogger.log("html:{}",html);
                }
            })
            .build();
    xxlCrawler.start(true);
    return SUCCESS;`

这是报错:
org.jsoup.HttpStatusException: HTTP error fetching URL. Status=400

@junyong-tsui
Copy link

内部代码不支持 post raw 方式,需要修改一下源码,放开requestbody赋值。

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

2 participants