From 06bae52bd7c31c7640be84c472bd940495c8a71e Mon Sep 17 00:00:00 2001 From: LambdaExpression Date: Thu, 19 May 2022 23:32:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E5=8B=BE=E9=80=89=E7=99=BB=E5=BD=95=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8D=8F=E8=AE=AE):=20chinaTelecom.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/chinaTelecom.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/chinaTelecom.go b/tools/chinaTelecom.go index 51ef7fa..d072950 100644 --- a/tools/chinaTelecom.go +++ b/tools/chinaTelecom.go @@ -102,6 +102,7 @@ func login(ctx context.Context, username, password string) { indexUrl := "https://e.189.cn/wap/index.do" var collectLink string var res string + var jAgreementCheckboxHtml string var b1, b2, b3 []byte var ck []*network.Cookie @@ -113,9 +114,28 @@ func login(ctx context.Context, username, password string) { chromedp.CaptureScreenshot(&b1), chromedp.Click(`j-other-login-way2`, chromedp.ByID), chromedp.WaitVisible(`j-login-btn`, chromedp.ByID), + chromedp.OuterHTML("j-agreement-checkbox", &jAgreementCheckboxHtml, chromedp.ByID), + ) + if err != nil { + configs.Logger.Error("error", err) + outLogonPng(b1, b2, b3) + return + } + + if !strings.Contains(jAgreementCheckboxHtml, "ag-ckbox") { + err = chromedp.Run(ctx, + chromedp.Click(`j-agreement-checkbox`, chromedp.ByID), + ) + if err != nil { + configs.Logger.Error("error", err) + outLogonPng(b1, b2, b3) + return + } + } + + err = chromedp.Run(ctx, chromedp.SendKeys(`j-userName`, username, chromedp.ByID), chromedp.SendKeys(`j-password`, password, chromedp.ByID), - //chromedp.Click(`j-agreement-checkbox`, chromedp.ByID), chromedp.Click(`j-login-btn`, chromedp.ByID), chromedp.CaptureScreenshot(&b2), chromedp.WaitVisible(`_userMobile`, chromedp.ByID),