例如URL: http://localhost:8080/javascritp/queryList/?params={"name":"aaa","limit":"45","sl":"show"} 應該是分紅兩個url來處理如: String url1 = "http://localhost:8080/javascritp/queryList/?params="; String url2 = URLEncoder.encode("{"name":"aaa","limit":"45","sl":"show"}","UTF-8"); //請求URL public static String get(String url, Map<String, String> headers, String charset, Integer connTimeout, Integer readTimeout) throws ConnectTimeoutException, SocketTimeoutException, Exception { HttpClient client = null; HttpGet get = new HttpGet(url); String result = ""; try { if (headers != null && !headers.isEmpty()) { for (Entry<String, String> entry : headers.entrySet()) { get.addHeader(entry.getKey(), entry.getValue()); } } // 設置參數 Builder customReqConf = RequestConfig.custom(); if (connTimeout != null) { customReqConf.setConnectTimeout(connTimeout); } if (readTimeout != null) { customReqConf.setSocketTimeout(readTimeout); } get.setConfig(customReqConf.build()); HttpResponse res = null; if (url.startsWith("https")) { // 執行 Https 請求. client = createSSLInsecureClient(); res = client.execute(get); } else { // 執行 Http 請求. client = HttpClientUtils.client; res = client.execute(get); } result = IOUtils.toString(res.getEntity().getContent(), charset); } finally { get.releaseConnection(); if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) { ((CloseableHttpClient) client).close(); } } return result; } //WebMagic處理get請求 Request request = new Request(); request.setMethod(HttpConstant.Method.GET); request.setUrl(url1+url2); //啓動爬蟲 Spider.create(new PageProcessor()) .addPipeline(new Pipline()) .addRequest(request) .run();