瀏覽代碼

增加验证码判断逻辑

xuzuoyun 5 年之前
父節點
當前提交
c2ce180135

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.graphql.service.impl;
 import cn.com.ctop.common.module.entity.HttpClientEntity;
 import cn.com.ctop.common.module.entity.HttpClientEntity;
 import cn.com.ctop.common.module.entity.IpPool;
 import cn.com.ctop.common.module.entity.IpPool;
 import cn.com.ctop.common.module.service.IIpPoolService;
 import cn.com.ctop.common.module.service.IIpPoolService;
+import cn.com.ctop.common.module.utils.Base64Utils;
+import cn.com.ctop.common.module.utils.ChaojiyingUtils;
 import cn.com.ctop.common.module.utils.HttpClientUtils;
 import cn.com.ctop.common.module.utils.HttpClientUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouPublicFeeds;
 import cn.com.ctop.kuaishou.modules.graphql.entity.KuaishouPublicFeeds;
@@ -611,6 +613,18 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             //等待2秒用于页面加载,保证Cookie响应全部获取。
             //等待2秒用于页面加载,保证Cookie响应全部获取。
             Thread.sleep(10000);
             Thread.sleep(10000);
 
 
+            WebElement iframeElement = webDriver.findElement(By.tagName("iframe"));
+            if (iframeElement != null) {
+                log.error("【错误】快手登录出现验证码!");
+//                File scrFile = captureElement(webDriver.findElement(By.tagName("iframe")));
+//                //clickCharBg
+//                String savePath = "D:/capter.png";
+//                FileUtils.copyFile(scrFile, new File(savePath));
+//                webDriver.switchTo().frame(webDriver.findElement(By.tagName("iframe")));
+//                String result = ChaojiyingUtils.process(Base64Utils.imageToBase64(savePath));
+//                System.out.println(result);
+//                ((JavascriptExecutor) webDriver).executeScript("arguments[0].click();", webDriver.findElement(By.className("aq_icon_refresh")));
+            }
             webDriver.get("https://b.e.kuaishou.com/#/home/profile");
             webDriver.get("https://b.e.kuaishou.com/#/home/profile");
             //获取Cookie并打印
             //获取Cookie并打印
             Set<org.openqa.selenium.Cookie> cookies = webDriver.manage().getCookies();
             Set<org.openqa.selenium.Cookie> cookies = webDriver.manage().getCookies();