1 sect := `//a[@href="v/443.json"]` 2 wd,_ := os.Getwd() 3 fmt.Println(wd) 4 return chromedp.Tasks{ 5 //chromedp.Navigate(url), 6 chromedp.WaitVisible(sect), 7 page.SetDownloadBehavior(page.SetDownloadBehaviorBehaviorAllow).WithDownloadPath(wd), 8 chromedp.Click(sect, chromedp.NodeVisible), 9 chromedp.Sleep(3 * time.Second), 10 }
加入page.SetDownloadBehavior(page.SetDownloadBehaviorBehaviorAllow).WithDownloadPath(wd),
這句就可以下載文件了,不過chrome顯示的情況下正常,如果chrome設置成headless的時候下載不正常,這個還需要進一步探索。
