|
|
@@ -2,18 +2,18 @@ package com.jzg.quotation.zijin.crawler.component;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.google.zxing.NotFoundException;
|
|
|
-import com.jzg.commons.exception.SystemException;
|
|
|
-import com.jzg.quotation.zijin.crawler.enums.RequestUrl;
|
|
|
+import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
+import com.jzg.quotation.commons.service.ExteriorUtilsRequest;
|
|
|
import com.jzg.quotation.zijin.crawler.entity.request.*;
|
|
|
import com.jzg.quotation.zijin.crawler.entity.response.*;
|
|
|
+import com.jzg.quotation.zijin.crawler.enums.RequestUrl;
|
|
|
import com.jzg.quotation.zijin.crawler.properties.ZiJinCrawlerProperties;
|
|
|
-import com.jzg.quotation.zijin.crawler.util.*;
|
|
|
-import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
+import com.jzg.quotation.zijin.crawler.util.DESEncryption;
|
|
|
+import com.jzg.quotation.zijin.crawler.util.RS6Item;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
@@ -21,7 +21,10 @@ import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @description: 紫金财险爬虫请求组件
|
|
|
@@ -39,9 +42,10 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
|
|
|
private final RequestComponent requestComponent;
|
|
|
|
|
|
-
|
|
|
private final ZiJinCrawlerProperties ziJinCrawlerProperties;
|
|
|
|
|
|
+ private final ExteriorUtilsRequest exteriorUtilsRequest;
|
|
|
+
|
|
|
/**
|
|
|
* 获取验证码
|
|
|
*
|
|
|
@@ -52,7 +56,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
ZiJinCrawlerCaptchaResponse ziJinCrawlerCaptchaResponse = null;
|
|
|
try {
|
|
|
if (frequency <= 0) {
|
|
|
- //throw new SystemException("验证码请求频次异常");
|
|
|
+ // throw new SystemException("验证码请求频次异常");
|
|
|
ziJinCrawlerCaptchaResponse = new ZiJinCrawlerCaptchaResponse();
|
|
|
ziJinCrawlerCaptchaResponse.setRtnCode("500");
|
|
|
ziJinCrawlerCaptchaResponse.setRtnMsg("验证码请求频次异常");
|
|
|
@@ -69,9 +73,11 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
ziJinCrawlerCaptchaResponse = responseEntity.getBody();
|
|
|
log.info("获取验证码接口响应内容:{}", JSON.toJSONString(ziJinCrawlerCaptchaResponse));
|
|
|
String captchaImg = ziJinCrawlerCaptchaResponse.getCaptchaImg();
|
|
|
- String captcha = captchaImg.split(",")[1].trim();
|
|
|
+ // String captcha = captchaImg.split(",")[1].trim();
|
|
|
// 识别验证码的内容
|
|
|
- String captchaContent = CaptchaUtil.performOCR(captcha);
|
|
|
+ // String captchaContent = CaptchaUtil.performOCR(captcha);
|
|
|
+ // 识别验证码
|
|
|
+ String captchaContent = exteriorUtilsRequest.captchaIdentify(captchaImg);
|
|
|
log.info("验证码内容:{}", captchaContent);
|
|
|
ziJinCrawlerCaptchaResponse.setCaptchaContent(captchaContent);
|
|
|
} catch (Exception e) {
|
|
|
@@ -110,7 +116,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
|
|
|
HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
httpHeaders.setContentLength(289);
|
|
|
- //需要单独设置这个
|
|
|
+ // 需要单独设置这个
|
|
|
httpHeaders.set("Authorization", token);
|
|
|
httpHeaders.set("loginToken", token);
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerCheckCaptchaRequest);
|
|
|
@@ -119,7 +125,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验token
|
|
|
+ * 校验token(Python没有这个接口)
|
|
|
*
|
|
|
* @param ziJinCrawlerCheckTokenRequest
|
|
|
* @param token
|
|
|
@@ -127,12 +133,12 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
*/
|
|
|
public ZiJinCrawlerCheckTokenResponse checkToken(ZiJinCrawlerCheckTokenRequest ziJinCrawlerCheckTokenRequest, String token) throws IOException {
|
|
|
log.info("ziJinCrawlerCheckTokenRequest请求参数的值:{}", JSON.toJSONString(ziJinCrawlerCheckTokenRequest));
|
|
|
-
|
|
|
HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
httpHeaders.setContentLength(66);
|
|
|
- //需要单独设置这个
|
|
|
+ // 需要单独设置这个
|
|
|
httpHeaders.set("Authorization", token);
|
|
|
httpHeaders.set("loginToken", token);
|
|
|
+
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerCheckTokenRequest);
|
|
|
ResponseEntity<ZiJinCrawlerCheckTokenResponse> responseEntity = requestComponent.post(RequestUrl.CHECK_TOKEN.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerCheckTokenResponse.class, httpHeaders);
|
|
|
return responseEntity.getBody();
|
|
|
@@ -150,9 +156,9 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
ZiJinCrawlerCaptchaResponse captcha = captcha(CIRCULATE_NUMBER);
|
|
|
// 登录存入缓存当中
|
|
|
ZiJinCrawlerAuthenticateRequest request = new ZiJinCrawlerAuthenticateRequest(captcha, username, password);
|
|
|
- //ZiJinCrawlerBaseRequest crawlerBaseRequest = new ZiJinCrawlerBaseRequest(request);
|
|
|
+ // ZiJinCrawlerBaseRequest crawlerBaseRequest = new ZiJinCrawlerBaseRequest(request);
|
|
|
ZiJinCrawlerBaseRequest crawlerBaseRequest = null;
|
|
|
- //return requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(""), crawlerBaseRequest, ZiJinCrawlerBaseResponse.class);
|
|
|
+ // return requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(""), crawlerBaseRequest, ZiJinCrawlerBaseResponse.class);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -165,7 +171,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return 获取渠道信息响应
|
|
|
*/
|
|
|
public ZiJinCrawlerGetSaleInfoResponse getSaleInfo(String operatorCode, HttpHeaders headers) {
|
|
|
- //String url = RequestUrl.GET_SALE_INFO.getRequestUrl("") + operatorCode;
|
|
|
+ // String url = RequestUrl.GET_SALE_INFO.getRequestUrl("") + operatorCode;
|
|
|
String url = "";
|
|
|
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
|
|
map.add("operatorCode", operatorCode);
|
|
|
@@ -181,8 +187,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerCarResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerCarResponse car(ZiJinCrawlerCarRequest ziJinCrawlerCarRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerCarRequest);
|
|
|
log.info("ziJinCrawlerCarRequest请求参数的值:{}", jsonString);
|
|
|
@@ -198,8 +204,9 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerCarResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerGetOrderNoResponse getOrderNo(ZiJinCrawlerGetOrderNoRequest ziJinCrawlerGetOrderNoRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
+
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerGetOrderNoRequest);
|
|
|
log.info("ziJinCrawlerGetOrderNoRequest请求参数的值:{}", jsonString);
|
|
|
ResponseEntity<ZiJinCrawlerGetOrderNoResponse> responseEntity = requestComponent.post(RequestUrl.GET_ORDER_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetOrderNoResponse.class, httpHeaders);
|
|
|
@@ -214,8 +221,9 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerGetCarActualValueResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerGetCarActualValueResponse getCarActualValue(ZiJinCrawlerGetCarActualValueRequest ziJinCrawlerGetCarActualValueRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
+
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerGetCarActualValueRequest);
|
|
|
log.info("ziJinCrawlerGetCarActualValueRequest请求参数的值:{}", jsonString);
|
|
|
ResponseEntity<ZiJinCrawlerGetCarActualValueResponse> responseEntity = requestComponent.post(RequestUrl.GET_ACTUAL_VALUE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetCarActualValueResponse.class, httpHeaders);
|
|
|
@@ -230,10 +238,17 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerGetTaxRegistryNumberResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerGetTaxRegistryNumberResponse getTaxRegistryNumber(String comCode, HttpHeaders headers) throws IOException {
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
- String url = RequestUrl.GET_TAX_REGISTRY_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl());
|
|
|
- log.info("获取税务登记证号请求URL:{}", url);
|
|
|
- ZiJinCrawlerGetTaxRegistryNumberResponse response = requestComponent.get(url, new LinkedMultiValueMap<>(), "", ZiJinCrawlerGetTaxRegistryNumberResponse.class, httpHeaders);
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
+ httpHeaders.remove("Cache-Control");
|
|
|
+ httpHeaders.remove("Content-Length");
|
|
|
+ httpHeaders.remove("Origin");
|
|
|
+ httpHeaders.remove("Pragma");
|
|
|
+ httpHeaders.remove("content-type");
|
|
|
+
|
|
|
+ LinkedMultiValueMap<String, String> parameterMap = new LinkedMultiValueMap<>();
|
|
|
+ parameterMap.add("comCode", comCode);
|
|
|
+ ZiJinCrawlerGetTaxRegistryNumberResponse response = requestComponent.get(RequestUrl.GET_TAX_REGISTRY_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), parameterMap, "", ZiJinCrawlerGetTaxRegistryNumberResponse.class, httpHeaders);
|
|
|
log.info("获取税务登记证号响应:{}", JSON.toJSONString(response));
|
|
|
return response;
|
|
|
}
|
|
|
@@ -246,8 +261,9 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerQuotationResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerQuotationResponse quotation(ZiJinCrawlerQuotationRequest ziJinCrawlerQuotationRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
+
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerQuotationRequest);
|
|
|
log.info("ziJinCrawlerQuotationRequest请求参数的值:{}", jsonString);
|
|
|
ResponseEntity<ZiJinCrawlerQuotationResponse> post = requestComponent.post(RequestUrl.PRICE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerQuotationResponse.class, httpHeaders);
|
|
|
@@ -258,13 +274,13 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* 验证码(报价出现转保标志)
|
|
|
*
|
|
|
* @param ziJinCrawlerRecognizeCodesRequest
|
|
|
- * @param headers 请求头
|
|
|
+ * @param headers 请求头
|
|
|
* @return ZiJinCrawlerRecognizeCodesResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerRecognizeCodesResponse recognizeCodes(List<ZiJinCrawlerRecognizeCodesRequest> ziJinCrawlerRecognizeCodesRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
- httpHeaders.set("Content-Type", "application/json");
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
+
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerRecognizeCodesRequest);
|
|
|
log.info("ziJinCrawlerRecognizeCodesRequest请求参数的值:{}", jsonString);
|
|
|
ResponseEntity<ZiJinCrawlerRecognizeCodesResponse> post = requestComponent.post(RequestUrl.SKIP_SING.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerRecognizeCodesResponse.class, httpHeaders);
|
|
|
@@ -279,8 +295,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerSaveQuoteInformationResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerSaveQuoteInfoResponse saveQuoteInformation(ZiJinCrawlerSaveQuoteInfoRequest ziJinCrawlerSaveQuoteInfoRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerSaveQuoteInfoRequest);
|
|
|
log.info("ziJinCrawlerSaveQuoteInfoRequest请求参数的值:{}", jsonString);
|
|
|
@@ -288,7 +304,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
return responseEntity.getBody();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 保存投保单
|
|
|
*
|
|
|
* @param ziJinCrawlerSaveProposalRequest
|
|
|
@@ -296,8 +312,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerSaveProposalResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerSaveProposalResponse saveProposal(ZiJinCrawlerSaveProposalRequest ziJinCrawlerSaveProposalRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerSaveProposalRequest);
|
|
|
log.info("ziJinCrawlerSaveProposalRequest请求参数的值:{}", jsonString);
|
|
|
@@ -314,8 +330,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerUnderwritingResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerUnderwritingResponse underwriting(ZiJinCrawlerUnderwritingRequest ziJinCrawlerUnderwritingRequest, HttpHeaders headers) throws Exception {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerUnderwritingRequest);
|
|
|
log.info("ziJinCrawlerUnderwritingRequest请求参数的值:{}", jsonString);
|
|
|
@@ -332,8 +348,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerImageUploadResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerImageUploadResponse uploadImage(ZiJinCrawlerImageUploadRequest ziJinCrawlerImageUploadRequest, HttpHeaders headers) throws Exception {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerImageUploadRequest);
|
|
|
log.info("ziJinCrawlerImageUploadRequest请求参数的值:{}", jsonString);
|
|
|
@@ -348,8 +364,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerImageUploadResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerImageUploadInfoListResponse uploadImageInfoList(ZiJinCrawlerUploadImageInfoListRequest ziJinCrawlerUploadImageInfoListRequest, HttpHeaders headers) throws Exception {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerUploadImageInfoListRequest);
|
|
|
log.info("ziJinCrawlerUploadImageInfoListRequest请求参数的值:{}", jsonString);
|
|
|
@@ -358,7 +374,6 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取支付链接
|
|
|
*
|
|
|
@@ -367,8 +382,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerPaymentLinkResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerPaymentLinkResponse payment(ZiJinCrawlerPaymentLinkRequest ziJinCrawlerPaymentLinkRequest, HttpHeaders headers) throws NotFoundException, IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerPaymentLinkRequest);
|
|
|
log.info("ziJinCrawlerPaymentLinkRequest请求参数的值:{}", jsonString);
|
|
|
@@ -384,8 +399,8 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerQueryOrderStatusResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerQueryOrderStatusResponse queryOrderStatus(ZiJinCrawlerQueryOrderStatusRequest ziJinCrawlerQueryOrderStatusRequest, HttpHeaders headers) throws IOException {
|
|
|
- //设置headers
|
|
|
- HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
+ String token = headers.getFirst("Authorization");
|
|
|
+ HttpHeaders httpHeaders = setHttpHeaders(token);
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerQueryOrderStatusRequest);
|
|
|
log.info("ziJinCrawlerQueryOrderStatusRequest请求参数的值:{}", jsonString);
|
|
|
@@ -454,7 +469,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerQueryCarPolicyListResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerQueryCarPolicyListResponse queryCarPolicyList(ZiJinCrawlerQueryCarPolicyListRequest ziJinCrawlerQueryCarPolicyListRequest) throws IOException {
|
|
|
- //设置headers
|
|
|
+ // 设置headers
|
|
|
HttpHeaders httpHeaders = setHttpHeaders1();
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerQueryCarPolicyListRequest);
|
|
|
@@ -471,7 +486,7 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @return ZiJinCrawlerDownloadResponse
|
|
|
*/
|
|
|
public ZiJinCrawlerDownloadPolicyResponse electronPolicyIODownload(ZiJinCrawlerDownloadPolicyRequest ziJinCrawlerDownloadPolicyRequest) throws IOException {
|
|
|
- //设置headers
|
|
|
+ // 设置headers
|
|
|
HttpHeaders httpHeaders = setHttpHeaders();
|
|
|
|
|
|
String jsonString = JSON.toJSONString(ziJinCrawlerDownloadPolicyRequest);
|
|
|
@@ -501,17 +516,18 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@NotNull
|
|
|
- private static HttpHeaders setHttpHeaders() throws IOException {
|
|
|
+ private HttpHeaders setHttpHeaders() throws IOException {
|
|
|
+ return setHttpHeaders(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private HttpHeaders setHttpHeaders(String token) throws IOException {
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
- //headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- //获取cookie的值
|
|
|
String cookie = getCookie();
|
|
|
headers.set("Cookie", "csrfToken=CrwLEmSfUevAb8PcN7kXff-I; "+ cookie);
|
|
|
- // 设置请求头
|
|
|
headers.set("Accept", "application/json, text/plain, */*, application/problem+json");
|
|
|
- //headers.set("Accept-Encoding", "gzip, deflate, br, zstd");
|
|
|
+ // headers.set("Accept-Encoding", "gzip, deflate, br, zstd");
|
|
|
headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
|
|
|
- headers.set("Authorization", "FD385C99C9B35B64EF84590AACA95380");
|
|
|
headers.set("Cache-Control", "no-cache");
|
|
|
headers.set("Connection", "keep-alive");
|
|
|
headers.set("Content-Length", "23");
|
|
|
@@ -524,17 +540,31 @@ public class ZiJinCrawlerRequestComponent {
|
|
|
headers.set("Sec-Fetch-Site", "same-origin");
|
|
|
headers.set("Tokentype", "DEFULT");
|
|
|
headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36");
|
|
|
- headers.set("loginToken", "FD385C99C9B35B64EF84590AACA95380");
|
|
|
headers.set("sec-ch-ua", "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"");
|
|
|
headers.set("sec-ch-ua-mobile", "?0");
|
|
|
headers.set("sec-ch-ua-platform", "\"Windows\"");
|
|
|
headers.set("x-csrf-token", "CrwLEmSfUevAb8PcN7kXff-I");
|
|
|
headers.set("content-type", "application/json");
|
|
|
+ if (StringUtils.hasText(token)) {
|
|
|
+ headers.set("Authorization", token);
|
|
|
+ headers.set("loginToken", token);
|
|
|
+ }
|
|
|
return headers;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构建带有authorization的HTTP请求头
|
|
|
+ *
|
|
|
+ * @param authorization 认证token
|
|
|
+ * @return HttpHeaders
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public HttpHeaders buildHttpHeaders(String authorization) throws IOException {
|
|
|
+ return setHttpHeaders(authorization);
|
|
|
+ }
|
|
|
+
|
|
|
@NotNull
|
|
|
- private HttpHeaders setHttpHeaders1(){
|
|
|
+ private HttpHeaders setHttpHeaders1() {
|
|
|
try {
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
String cookie = getCookie();
|