Tools.download 添加UA标签

This commit is contained in:
yutou 2020-10-30 10:13:25 +08:00
parent 55722ac9c1
commit 3fe153d2c4

View File

@ -290,6 +290,7 @@ public class Tools {
public static void download(String url, DownloadInterface downloadInterface) { public static void download(String url, DownloadInterface downloadInterface) {
try { try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36");
connection.disconnect(); connection.disconnect();
new File("tmp").mkdirs(); new File("tmp").mkdirs();
File file = new File("tmp" + File.separator + url.trim().split("/")[url.trim().split("/").length - 1]); File file = new File("tmp" + File.separator + url.trim().split("/")[url.trim().split("/").length - 1]);