...
package main import ( "fmt" "log" "time" "github.com/go-rod/rod" "github.com/go-rod/rod/lib/launcher" ) type TbPars struct { NavUrl string // first url requst PreElm string // xpath to loc pre elm DataSel string Ln, Col int PageCount int Next string } func (t *TbPars) Pars() { path, _ := launcher.LookPath() u := launcher.New().Delete("--headless").Set("--window-size=1920,1080").Bin(path).MustLaunch() brs := rod.New().ControlURL(u).MustConnect() page := brs.MustPage(t.NavUrl).MustWaitLoad() log.Println("flag1====") page.Mouse.MustScroll(1600, 1600) page.MustElement(t.PreElm).MustClick() log.Println("flag====") // page.Keyboard.MustPress(35) elm := page.MustElementX(`/html/body/div[1]/table/tbody/tr[7]/td[1]/div`) text := elm.MustText() log.Println(text) for i := 1; i <= t.Ln; i++ { ln := []string{} for j := 1; j <= t.Col; j++ { sel := fmt.Sprintf(t.DataSel, i, j) // log.Println(i, j, sel) text := page.MustElementX(sel).MustText() log.Println("get ===>", text) ln = append(ln, text) } log.Println(ln) } time.Sleep(30 * time.Second) } func Foo() { t := TbPars{ NavUrl: "https://www.eiguleo.com", // PreElm: "#tab-de", PreElm: "#tab-eigu", DataSel: "/html/body/div[1]/div[2]/div[1]/div/div[3]/table/tbody/tr[%d]/td[%d]/div", Ln: 10, Col: 9, PageCount: 18, Next: "#eigu-app > div.content", } t.Pars() } func main() { Foo() }