-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
58 lines (57 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
//import (
// "context"
// "io/ioutil"
// "log"
//
// "github.com/chromedp/cdproto/cdp"
// "github.com/chromedp/chromedp"
//)
//
//func main() {
// var err error
//
// // create context
// ctxt, cancel := context.WithCancel(context.Background())
// defer cancel()
//
// // create chrome instance
// c, err := chromedp.New(ctxt, chromedp.WithLog(log.Printf))
// if err != nil {
// log.Fatal(err)
// }
//
// // run task list
// var site, res string
// url := "https://github.com/chromedp/chromedp"
// err = c.Run(ctxt, task(url, &site, &res))
// if err != nil {
// log.Fatal(err)
// }
//
// // shutdown chrome
// err = c.Shutdown(ctxt)
// if err != nil {
// log.Fatal(err)
// }
//
// // wait for chrome to finish
// err = c.Wait()
// if err != nil {
// log.Fatal(err)
// }
//
// log.Printf("saved screenshot from search result listing `%s` (%s)", res, site)
//}
//
//func task(url string, site, res *string) chromedp.Tasks {
// var buf []byte
// return chromedp.Tasks{
// chromedp.Navigate(url),
// chromedp.WaitVisible(`#hovercard-aria-description`, chromedp.ByID),
// chromedp.Location(site),
// chromedp.ActionFunc(func(context.Context, cdp.Executor) error {
// return ioutil.WriteFile("screenshot.png", buf, 0644)
// }),
// }
//}