跳转地址加入useragent
This commit is contained in:
parent
28f214fe6e
commit
72c3538df5
|
@ -1,5 +1,7 @@
|
|||
package com.chint.interfaces.rest.base;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -112,6 +114,9 @@ public class PostRequest {
|
|||
|
||||
public String getReDirectUrl(String url) {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
|
||||
String androidUserAgent = "Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36";
|
||||
|
||||
if (reDirectUrlCache.containsKey(url)) {
|
||||
CachedUrl cachedUrl = reDirectUrlCache.get(url);
|
||||
if (cachedUrl.getTimestamp() > System.currentTimeMillis()) {
|
||||
|
@ -121,6 +126,8 @@ public class PostRequest {
|
|||
int i = Runtime.getRuntime().availableProcessors();
|
||||
log.info("执行get前,当前线程数为" + i);
|
||||
HttpGet request = new HttpGet(url); // 替换为你的URL
|
||||
request.setHeader("User-Agent", androidUserAgent);
|
||||
|
||||
// 配置请求以禁用重定向
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setRedirectsEnabled(false)
|
||||
|
|
Loading…
Reference in New Issue