2025-02-21 18:49:58 +08:00
|
|
|
|
package method
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"dt_automate/tool"
|
|
|
|
|
"log"
|
|
|
|
|
|
|
|
|
|
"github.com/playwright-community/playwright-go"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func ZWW_FW1() {
|
|
|
|
|
// 启动 Playwright
|
|
|
|
|
pw, err := playwright.Run()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not start Playwright: %v", err)
|
|
|
|
|
}
|
|
|
|
|
defer pw.Stop()
|
|
|
|
|
|
|
|
|
|
// 启动浏览器(Chromium)
|
|
|
|
|
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
|
|
|
|
Headless: playwright.Bool(false), // 设置为 false 以显示浏览器界面
|
|
|
|
|
Args: []string{
|
|
|
|
|
"--ignore-certificate-errors", // 忽略证书错误[^28^][^29^]
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not launch browser: %v", err)
|
|
|
|
|
}
|
|
|
|
|
defer browser.Close()
|
|
|
|
|
|
|
|
|
|
// 创建一个新页面
|
|
|
|
|
page, err := browser.NewPage()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not create page: %v", err)
|
|
|
|
|
}
|
|
|
|
|
// 设置浏览器窗口大小
|
|
|
|
|
err = page.SetViewportSize(1920, 1080) // 宽度为 1200px,高度为 800px
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("无法设置浏览器窗口大小: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 导航到指定网址
|
|
|
|
|
_, err = page.Goto("https://11.1.68.146")
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not go to the page: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page.WaitForTimeout(2000)
|
|
|
|
|
//输入
|
2025-03-11 16:04:26 +08:00
|
|
|
|
if err := page.Locator(`#user_name`).Fill(tool.KeyStr("TpnsnRkoJQdgNfgHnoLzDwIJr8N3+oFVvSbONfzOulY+2ASjZjhP6NdIkD8+tsJrVeyfuNlXtUezKKteVFLYed6T9OTDInwlsmgoS9urJRGIzUbzTY57P+ubQD1/rI526/+/79bImaVo9UyjPKD358Yx90/vFlpwt34B0Jt/FifSRyqp9MoI9dE/GJGoaSDbVuDjBB8/lz6cSPM8ZDYaersKrwePsWlk9Q44jhz9ZXceg/Yfqd15fxmNaTAMHUuMpTehS8yZ+Gl0ts8zCV4V3zIVNG4IqpHNvF53wbpmEePkuaFrR4AqNPdLqkl7/GtgT8tnAVXzno/eNbI6ZhZ3rw==")); err != nil {
|
2025-02-21 18:49:58 +08:00
|
|
|
|
log.Fatalf("could not fill input: %v", err)
|
|
|
|
|
}
|
2025-03-11 16:04:26 +08:00
|
|
|
|
if err := page.Locator(`#password`).Fill(tool.KeyStr("kYDkp5HDFY5iiZWHLr3ha5CqyNrb/Y/UnqmEEzDUS25gYHM6EChiTYbp5/LVWy3Bl+MR6fTtk288+2ouR3q5WifG3RMaFeFpQz4C7mH5QcxW4pBw9ThPkVau6PlO2v+7xGLhlo9X/fJLcp6nyAsCWbx6FrYQcahcRKJ9cmGisadcS2o6CrkNdcgbWNGkmSlRKF5QCzg6w0aItNC4z5qgIHb+XNHTTkolmqbu7z3HBEdHw0gDCMTIioDfoBSynhRWoXtZv8TM2xkBqRkEFmvlmNf5kmU7HyB6w+mm6GoIxmThddTM9i49XWq7dUbXyKQt5Gtyq8fJjBGfS0MwOTBwTg==")); err != nil {
|
2025-02-21 18:49:58 +08:00
|
|
|
|
log.Fatalf("could not fill input: %v", err)
|
|
|
|
|
}
|
|
|
|
|
//登录
|
|
|
|
|
if err := page.Locator("#login_button").Click(); err != nil {
|
|
|
|
|
log.Fatalf("could not click button: %v", err)
|
|
|
|
|
}
|
|
|
|
|
page.WaitForTimeout(1000)
|
|
|
|
|
page.Evaluate(`
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const year = now.getFullYear();
|
|
|
|
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
|
const day = now.getDate().toString().padStart(2, '0');
|
|
|
|
|
const hours = now.getHours().toString().padStart(2, '0');
|
|
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
|
|
|
const timestamp = year+"-"+month+"-"+day +" "+ hours+":"+minutes+":"+seconds;
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
div.style.position = 'fixed';
|
|
|
|
|
div.style.bottom = '10px';
|
|
|
|
|
div.style.right = '10px';
|
|
|
|
|
div.style.color = 'white';
|
|
|
|
|
div.style.backgroundColor = 'black';
|
|
|
|
|
div.style.padding = '5px';
|
|
|
|
|
div.style.borderRadius = '5px';
|
|
|
|
|
div.textContent = timestamp;
|
|
|
|
|
document.body.appendChild(div);
|
|
|
|
|
`, nil)
|
|
|
|
|
page.Locator(`#leftmenu-body tr[data-recordid="M_ThreatLog"] div.x-grid-cell-inner.x-grid-cell-inner-treecolumn a.x-tree-node-text`).Click()
|
2025-02-25 18:36:33 +08:00
|
|
|
|
page.WaitForTimeout(2000)
|
2025-02-21 18:49:58 +08:00
|
|
|
|
page.Locator(`#button-1174-btnEl`).Click()
|
2025-02-25 18:36:33 +08:00
|
|
|
|
page.WaitForTimeout(1000)
|
2025-02-21 18:49:58 +08:00
|
|
|
|
page.Locator(`#combobox-1302-bodyEl #combobox-1302-inputEl`).Click()
|
2025-02-25 18:36:33 +08:00
|
|
|
|
page.WaitForTimeout(1000)
|
2025-03-05 18:55:51 +08:00
|
|
|
|
page.Locator(`#boundlist-1330-listEl li[title="yunwei"]`).Click()
|
2025-02-21 18:49:58 +08:00
|
|
|
|
page.WaitForTimeout(500)
|
|
|
|
|
page.Locator(`#combobox-1303-bodyEl #combobox-1303-inputEl`).Click()
|
|
|
|
|
page.WaitForTimeout(500)
|
|
|
|
|
page.Locator(`#boundlist-1335-listEl li[title="Trust"]`).Click()
|
|
|
|
|
page.WaitForTimeout(500)
|
|
|
|
|
page.Locator(`#button-1322-btnIconEl`).Click()
|
|
|
|
|
page.WaitForTimeout(1000)
|
|
|
|
|
// page.Screenshot(playwright.PageScreenshotOptions{
|
|
|
|
|
// Path: playwright.String("img/hw_fw1.png"),
|
|
|
|
|
// FullPage: playwright.Bool(true),
|
|
|
|
|
// })
|
|
|
|
|
tool.Jietu("img/zww_fw1.png")
|
|
|
|
|
page.WaitForTimeout(2000)
|
|
|
|
|
// 获取页面标题
|
|
|
|
|
title, err := page.Title()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not get title: %v", err)
|
|
|
|
|
}
|
|
|
|
|
log.Printf("Page title is: %s\n", title)
|
|
|
|
|
|
|
|
|
|
// StartBlocker()
|
|
|
|
|
page.WaitForTimeout(5000)
|
|
|
|
|
}
|