标签:usermod rac print 选择 arch str output use usermode
package main import ( "fmt" "time" "github.com/ysmood/rod" "github.com/ysmood/rod/lib/input" "github.com/ysmood/rod/lib/launcher" ) func Example_reuse_sessions() { url := launcher.NewUserMode().Launch() browser := rod.New().ControlURL(url).Connect() page := browser.Timeout(time.Second * 15).Page("https://www.baidu.com") page.Window(0, 0, 1920, 1080) // use css selector to get the search input element and input "git" page.Element("#kw").Input("测试").Press(input.Enter) // wait until css selector get the element then get the text content of it text := page.Element(`#\31 > div.c-abstract`).Text() //这里的选择器selector是从chrome控制台中copy的。 fmt.Println(text) fmt.Println("done") // Skip // Output: done } func main() { Example_reuse_sessions() for { } }
比较简洁、直观。
标签:usermod rac print 选择 arch str output use usermode
原文地址:https://www.cnblogs.com/pu369/p/12844917.html