Browse Source

更换代理

xueyiming 4 months ago
parent
commit
a74cc93d6e

+ 23 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/controller/IndexController.java

@@ -1,12 +1,19 @@
 package com.tzld.piaoquan.longarticle.controller;
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
 import com.tzld.piaoquan.longarticle.service.local.impl.MatchVideoServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_HOST;
+import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_PORT;
+
+@Slf4j
 @RestController
 @RequestMapping("/")
 public class IndexController {
@@ -22,4 +29,20 @@ public class IndexController {
     }
 
 
+    @GetMapping("/test")
+    public String test() {
+
+        // 目标网站
+        String url = "https://www.baidu.com";
+
+        // 发送请求
+        HttpResponse result = HttpRequest.get(url)
+                .setHttpProxy(PROXY_HOST, PROXY_PORT)
+                .timeout(20000)//设置超时,毫秒
+                .execute();
+        log.info("test={}", result.body());
+        return "ok";
+    }
+
+
 }

+ 0 - 9
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/job/PlanAccountJob.java

@@ -9,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
-import static com.tzld.piaoquan.longarticle.common.constants.RedisConstant.REDIS_COOKIE_KEY;
-
 @Slf4j
 @Component
 public class PlanAccountJob {
@@ -76,11 +74,4 @@ public class PlanAccountJob {
         }
         return ReturnT.SUCCESS;
     }
-
-    @XxlJob("updateCookieJob")
-    public ReturnT<String> updateCookie(String param) {
-        redisTemplate.opsForValue().set(REDIS_COOKIE_KEY, param);
-        return ReturnT.SUCCESS;
-    }
-
 }