new
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 182 KiB |
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 244 KiB |
BIN
img/capt.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
img/hw_fw1.png
Before Width: | Height: | Size: 386 KiB After Width: | Height: | Size: 384 KiB |
BIN
img/zww_fw1.png
Normal file
After Width: | Height: | Size: 184 KiB |
BIN
img/zww_tsgz.png
Normal file
After Width: | Height: | Size: 132 KiB |
5
main.go
@ -92,6 +92,11 @@ func main() {
|
|||||||
//互联网区
|
//互联网区
|
||||||
method.HW_FAC1() //截取流量清洗的图片
|
method.HW_FAC1() //截取流量清洗的图片
|
||||||
method.HW_FW1() //截取防火墙的图片
|
method.HW_FW1() //截取防火墙的图片
|
||||||
|
method.HW_TSGZ() //截取态势感知的图片
|
||||||
|
//政务网区
|
||||||
|
method.ZWW_FW1() //截取防火墙的图片
|
||||||
|
method.ZWW_TSGZ() //截取态势感知的图片
|
||||||
|
// wps.Word()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Println("没有授权")
|
log.Println("没有授权")
|
||||||
|
121
method/hw_tsgz.go
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
package method
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dt_automate/tool"
|
||||||
|
"dt_automate/wtch_ocr"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/playwright-community/playwright-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func HW_TSGZ() {
|
||||||
|
// 启动 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.2.65.21/")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("could not go to the page: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
page.WaitForTimeout(2000)
|
||||||
|
page.Locator(`.verification-item .el-image`).Screenshot(playwright.LocatorScreenshotOptions{
|
||||||
|
Path: playwright.String("img/capt.png"),
|
||||||
|
})
|
||||||
|
a := page.Locator(`.el-input__inner`)
|
||||||
|
result := wtch_ocr.OcrDefault("img/capt.png")
|
||||||
|
if len(result.OcrResponse[0].Text) == 4 {
|
||||||
|
log.Println("读取验证码:", result.OcrResponse[0].Text)
|
||||||
|
a.Nth(2).Fill(result.OcrResponse[0].Text)
|
||||||
|
} else {
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(".verification-item .el-image .el-image__inner").Click()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Screenshot(playwright.PageScreenshotOptions{})
|
||||||
|
// (playwright.PageScreenshotOptions{
|
||||||
|
// Path: playwright.String("img/capg.png"),
|
||||||
|
// FullPage: playwright.Bool(true),
|
||||||
|
// })
|
||||||
|
//输入
|
||||||
|
a.Nth(0).Fill("admin")
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
a.Nth(1).Fill("BWySN~QjrlwFsA)@#h")
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
//点击同意
|
||||||
|
if err := page.Locator(`.el-checkbox__inner`).Click(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
//登录
|
||||||
|
page.WaitForTimeout(1000)
|
||||||
|
if err := page.Locator(`.el-button.el-button--primary.el-button--large.login-button`).Click(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
_, err = page.Goto("https://11.2.65.21/#/threatCenter/asset")
|
||||||
|
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(`.el-range-input`).Nth(0).Click()
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(`.el-picker-panel__shortcut`).Nth(0).Click()
|
||||||
|
page.WaitForTimeout(300)
|
||||||
|
page.Locator(`.display-inline-flex.align-items-center.justify-content-end.advanced-search-wrapper .el-button.el-button--primary`).Click()
|
||||||
|
page.WaitForTimeout(1000)
|
||||||
|
tool.Jietu("img/hw_tsgz.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)
|
||||||
|
}
|
109
method/zww_fw1.go
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
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)
|
||||||
|
//输入
|
||||||
|
if err := page.Locator(`#user_name`).Fill("xunjianyuan"); err != nil {
|
||||||
|
log.Fatalf("could not fill input: %v", err)
|
||||||
|
}
|
||||||
|
if err := page.Locator(`#password`).Fill("zwW47dNZN^tU2WjbY"); err != nil {
|
||||||
|
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()
|
||||||
|
page.WaitForTimeout(1000)
|
||||||
|
page.Locator(`#button-1174-btnEl`).Click()
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(`#combobox-1302-bodyEl #combobox-1302-inputEl`).Click()
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(`#boundlist-1330-listEl li[title="Untrust"]`).Click()
|
||||||
|
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)
|
||||||
|
}
|
121
method/zww_tsgz.go
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
package method
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dt_automate/tool"
|
||||||
|
"dt_automate/wtch_ocr"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/playwright-community/playwright-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ZWW_TSGZ() {
|
||||||
|
// 启动 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.65.20")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("could not go to the page: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
page.WaitForTimeout(2000)
|
||||||
|
page.Locator(`.verification-item .el-image`).Screenshot(playwright.LocatorScreenshotOptions{
|
||||||
|
Path: playwright.String("img/capt.png"),
|
||||||
|
})
|
||||||
|
a := page.Locator(`.el-input__inner`)
|
||||||
|
result := wtch_ocr.OcrDefault("img/capt.png")
|
||||||
|
if len(result.OcrResponse[0].Text) == 4 {
|
||||||
|
log.Println("读取验证码:", result.OcrResponse[0].Text)
|
||||||
|
a.Nth(2).Fill(result.OcrResponse[0].Text)
|
||||||
|
} else {
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(".verification-item .el-image .el-image__inner").Click()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Screenshot(playwright.PageScreenshotOptions{})
|
||||||
|
// (playwright.PageScreenshotOptions{
|
||||||
|
// Path: playwright.String("img/capg.png"),
|
||||||
|
// FullPage: playwright.Bool(true),
|
||||||
|
// })
|
||||||
|
//输入
|
||||||
|
a.Nth(0).Fill("admin")
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
a.Nth(1).Fill("tov6LeR*R6Or_jiUC")
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
//点击同意
|
||||||
|
if err := page.Locator(`.el-checkbox__inner`).Click(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
//登录
|
||||||
|
page.WaitForTimeout(1000)
|
||||||
|
if err := page.Locator(`.el-button.el-button--primary.el-button--large.login-button`).Click(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
_, err = page.Goto("https://11.1.65.20/#/threatCenter/asset")
|
||||||
|
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(`.el-range-input`).Nth(0).Click()
|
||||||
|
page.WaitForTimeout(500)
|
||||||
|
page.Locator(`.el-picker-panel__shortcut`).Nth(0).Click()
|
||||||
|
page.WaitForTimeout(300)
|
||||||
|
page.Locator(`.display-inline-flex.align-items-center.justify-content-end.advanced-search-wrapper .el-button.el-button--primary`).Click()
|
||||||
|
page.WaitForTimeout(1000)
|
||||||
|
tool.Jietu("img/zww_tsgz.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)
|
||||||
|
}
|
BIN
simple.docx
Normal file
135
wps/word.go
@ -1,11 +1,9 @@
|
|||||||
package wps
|
package wps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/unidoc/unioffice/v2/color"
|
|
||||||
"github.com/unidoc/unioffice/v2/common"
|
"github.com/unidoc/unioffice/v2/common"
|
||||||
"github.com/unidoc/unioffice/v2/common/license"
|
"github.com/unidoc/unioffice/v2/common/license"
|
||||||
"github.com/unidoc/unioffice/v2/document"
|
"github.com/unidoc/unioffice/v2/document"
|
||||||
@ -30,85 +28,110 @@ func Word() {
|
|||||||
doc := document.New()
|
doc := document.New()
|
||||||
defer doc.Close()
|
defer doc.Close()
|
||||||
|
|
||||||
para := doc.AddParagraph() //添加段落
|
// para := doc.AddParagraph() //添加段落
|
||||||
run := para.AddRun() //添加运行
|
// run := para.AddRun() //添加运行
|
||||||
para.SetStyle("Title") //标题
|
// para.SetStyle("Title") //标题
|
||||||
run.AddText("Simple Document Formatting") //添加文本
|
// run.AddText("Simple Document Formatting") //添加文本
|
||||||
|
|
||||||
para = doc.AddParagraph()
|
// para = doc.AddParagraph()
|
||||||
para.SetStyle("Heading1") //标题1
|
// para.SetStyle("Heading1") //标题1
|
||||||
run = para.AddRun()
|
// run = para.AddRun()
|
||||||
run.AddText("Some Heading Text")
|
// run.AddText("Some Heading Text")
|
||||||
|
|
||||||
para = doc.AddParagraph()
|
// para = doc.AddParagraph()
|
||||||
para.SetStyle("Heading2") //标题2
|
// para.SetStyle("Heading2") //标题2
|
||||||
run = para.AddRun()
|
// run = para.AddRun()
|
||||||
run.AddText("Some Heading Text")
|
// run.AddText("Some Heading Text")
|
||||||
|
|
||||||
|
// para = doc.AddParagraph()
|
||||||
|
// para.SetStyle("Heading3") //标题3
|
||||||
|
// run = para.AddRun()
|
||||||
|
// run.AddText("Some Heading Text")
|
||||||
|
//标题
|
||||||
|
para := doc.AddParagraph()
|
||||||
|
para.Properties().SetAlignment(wml.ST_JcCenter)
|
||||||
|
run := para.AddRun()
|
||||||
|
run.Properties().SetBold(true)
|
||||||
|
run.Properties().SetFontFamily("等线 (正文)")
|
||||||
|
run.Properties().SetSize(22)
|
||||||
|
run.AddText("安全运维日报")
|
||||||
|
run.AddBreak()
|
||||||
|
//正文
|
||||||
para = doc.AddParagraph()
|
para = doc.AddParagraph()
|
||||||
para.SetStyle("Heading3") //标题3
|
para.Properties().SetFirstLineIndent(0.5 * measurement.Inch) //控制段落中第一行的缩进
|
||||||
run = para.AddRun()
|
run = para.AddRun()
|
||||||
run.AddText("Some Heading Text")
|
run.Properties().SetFontFamily("等线 (正文)")
|
||||||
|
run.Properties().SetSize(16) //设置字体大小
|
||||||
|
run.AddText(`2025年在政府信息化中心领导的指导、要求下,我科室和运维公司将严格加强网络安全巡检,每日做好巡检工作。 2025年2月20日对大同信创云平台互联网防火墙(*.*.68.146)、互联网流量清洗(*.*.65.19)、互联网态势感知(*.*.65.21)、互联网堡垒机(*.*.65.23)、政务外网防火墙(*.*.68.145)政务外网态势感知(*.*.65.20)、政务外网堡垒机(*.*.65.22)进行安全巡检,未发现安全入侵事件,安全设备运行正常。检测到攻击事件如下:`) //段落
|
||||||
|
|
||||||
para = doc.AddParagraph()
|
para = doc.AddParagraph()
|
||||||
para.Properties().SetFirstLineIndent(0.5 * measurement.Inch) //控制段落中第一行的缩进
|
para.Properties().SetFirstLineIndent(0.5 * measurement.Inch) //控制段落中第一行的缩进
|
||||||
|
|
||||||
run = para.AddRun()
|
run = para.AddRun()
|
||||||
run.AddText("A run is a string of characters with the same formatting. ") //段落
|
run.Properties().SetFontFamily("等线 (正文)")
|
||||||
|
run.Properties().SetSize(16)
|
||||||
|
run.AddText(`121.30.199.80:80、121.30.199.79:80服务受到wget 命令注入(HTTP_URI)攻击攻击,已对攻击源:91.224.92.10进行封锁;`)
|
||||||
|
|
||||||
|
para = doc.AddParagraph()
|
||||||
|
para.Properties().SetFirstLineIndent(0.5 * measurement.Inch) //控制段落中第一行的缩进
|
||||||
run = para.AddRun()
|
run = para.AddRun()
|
||||||
run.Properties().SetBold(true) //设置为粗体
|
run.Properties().SetFontFamily("等线 (正文)")
|
||||||
run.Properties().SetFontFamily("Courier") //设置字体系列
|
run.Properties().SetSize(16)
|
||||||
run.Properties().SetSize(15) //设置字体大小
|
run.AddText("121.30.199.82:80服务受到wget 命令注入(HTTP_URI)、Trojan.Win.Njrat变体出站连接、恶意软件流量_AndroxGh0st、访问敏感文件.git_config通信流量攻击攻击,已对攻击源:66.240.205.34、45.125.66.249、195.178.110.163进行封锁;")
|
||||||
run.Properties().SetColor(color.Red) //设置字体颜色
|
run.AddBreak()
|
||||||
run.AddText("Multiple runs with different formatting can exist in the same paragraph. ") //文字内容
|
run.AddText("如下为安全巡检详情:")
|
||||||
|
run.AddPageBreak()
|
||||||
|
|
||||||
|
para = doc.AddParagraph()
|
||||||
|
para.Properties().SetAlignment(wml.ST_JcCenter)
|
||||||
run = para.AddRun()
|
run = para.AddRun()
|
||||||
run.AddText("Adding breaks to a run will insert line breaks after the run. ")
|
run.Properties().SetBold(true)
|
||||||
run.AddBreak() //添加分隔符
|
run.Properties().SetFontFamily("等线 (正文)")
|
||||||
run.AddBreak() //添加分隔符
|
run.Properties().SetSize(22)
|
||||||
|
run.AddText("大同信创云平台安全运维日报")
|
||||||
|
run.AddBreak()
|
||||||
|
table := doc.AddTable()
|
||||||
|
row := table.AddRow()
|
||||||
|
// run = createParaRun(doc, "Runs support styling options:")
|
||||||
|
|
||||||
run = createParaRun(doc, "Runs support styling options:")
|
// run = createParaRun(doc, "small caps")
|
||||||
|
// run.Properties().SetSmallCaps(true) //设置小型大写字母
|
||||||
|
|
||||||
run = createParaRun(doc, "small caps")
|
// run = createParaRun(doc, "strike")
|
||||||
run.Properties().SetSmallCaps(true) //设置小型大写字母
|
// run.Properties().SetStrikeThrough(true) //设置删除线
|
||||||
|
|
||||||
run = createParaRun(doc, "strike")
|
// run = createParaRun(doc, "double strike")
|
||||||
run.Properties().SetStrikeThrough(true) //设置删除线
|
// run.Properties().SetDoubleStrikeThrough(true) //设置双删除线
|
||||||
|
|
||||||
run = createParaRun(doc, "double strike")
|
// run = createParaRun(doc, "outline")
|
||||||
run.Properties().SetDoubleStrikeThrough(true) //设置双删除线
|
// run.Properties().SetOutline(true) //设定线
|
||||||
|
|
||||||
run = createParaRun(doc, "outline")
|
// run = createParaRun(doc, "emboss")
|
||||||
run.Properties().SetOutline(true) //设定线
|
// run.Properties().SetEmboss(true) //设置浮雕
|
||||||
|
|
||||||
run = createParaRun(doc, "emboss")
|
// run = createParaRun(doc, "shadow")
|
||||||
run.Properties().SetEmboss(true) //设置浮雕
|
// run.Properties().SetShadow(true) //设置阴影
|
||||||
|
|
||||||
run = createParaRun(doc, "shadow")
|
// run = createParaRun(doc, "imprint")
|
||||||
run.Properties().SetShadow(true) //设置阴影
|
// run.Properties().SetImprint(true) //设置印记
|
||||||
|
|
||||||
run = createParaRun(doc, "imprint")
|
// run = createParaRun(doc, "highlighting")
|
||||||
run.Properties().SetImprint(true) //设置印记
|
// run.Properties().SetHighlight(wml.ST_HighlightColorYellow) //设置高亮显示
|
||||||
|
|
||||||
run = createParaRun(doc, "highlighting")
|
// run = createParaRun(doc, "underline")
|
||||||
run.Properties().SetHighlight(wml.ST_HighlightColorYellow) //设置高亮显示
|
// run.Properties().SetUnderline(wml.ST_UnderlineWavyDouble, color.Red) //设置下划线
|
||||||
|
|
||||||
run = createParaRun(doc, "underline")
|
// run = createParaRun(doc, "text effects")
|
||||||
run.Properties().SetUnderline(wml.ST_UnderlineWavyDouble, color.Red) //设置下划线
|
// run.Properties().SetEffect(wml.ST_TextEffectAntsRed) //设置效果
|
||||||
|
|
||||||
run = createParaRun(doc, "text effects")
|
// nd := doc.Numbering.Definitions()[0]
|
||||||
run.Properties().SetEffect(wml.ST_TextEffectAntsRed) //设置效果
|
|
||||||
|
|
||||||
nd := doc.Numbering.Definitions()[0]
|
// for i := 1; i < 5; i++ {
|
||||||
|
// p := doc.AddParagraph()
|
||||||
for i := 1; i < 5; i++ {
|
// p.SetNumberingLevel(i - 1) //设置数字级别
|
||||||
p := doc.AddParagraph()
|
// p.SetNumberingDefinition(nd) //集合编号定义
|
||||||
p.SetNumberingLevel(i - 1) //设置数字级别
|
// run := p.AddRun()
|
||||||
p.SetNumberingDefinition(nd) //集合编号定义
|
// run.AddText(fmt.Sprintf("Level %d", i))
|
||||||
run := p.AddRun()
|
// }
|
||||||
run.AddText(fmt.Sprintf("Level %d", i))
|
|
||||||
}
|
|
||||||
doc.SaveToFile("simple.docx")
|
doc.SaveToFile("simple.docx")
|
||||||
}
|
}
|
||||||
func createParaRun(doc *document.Document, s string) document.Run {
|
func createParaRun(doc *document.Document, s string) document.Run {
|
||||||
|