code4craft / webmagic

A scalable web crawler framework for Java.
http://webmagic.io/
Apache License 2.0
11.42k stars 4.18k forks source link

请求本地服务 响应报:400 Bad Request #1162

Open maskainv opened 6 months ago

maskainv commented 6 months ago

测试代码:
Request request = new Request("http://*.*.*.*:3036/xxxxxx/xx/xx/xx/zz/releaseList"); request.setMethod("GET"); request.getHeaders().put("Authorization", "49ee2c7a-67b7-42cc-ad95-0ae05d25de42"); request.getHeaders().put("Content-Type", "application/json"); Spider spider = Spider.create(new MyPageHandler()) .addRequest(request) .addPipeline(new ConsolePipeline()) .thread(1); spider.getSite().addHeader("Authorization", "49ee2c7a-67b7-42cc-ad95-0ae05d25de42"); spider.run();

自己写了一个download 直接使用hutool的请求工具类直接执行: HttpResponse serviceProfile = HttpRequest.get(url).addHeaders(request.getHeaders()).execute(); 是可以正常有响应报文的,不知道啥情况?