Skip to content

Commit be4b944

Browse files
author
xqs
committed
设置UA
1 parent 92cc8e8 commit be4b944

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/devil/utils/HttpUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ private static String getString(InputStream inputStream, Charset cs) throws IOEx
286286

287287
private static synchronized CloseableHttpClient getHttpClient() {
288288
if (null == customerHttpClient) {
289-
customerHttpClient = HttpClients.custom().setDefaultRequestConfig(conf).build();
289+
String UA = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36";
290+
customerHttpClient = HttpClients.custom().setDefaultRequestConfig(conf).setUserAgent(UA).build();
290291
}
291292
return customerHttpClient;
292293
}

0 commit comments

Comments
 (0)