Skip to content

Commit 8efce51

Browse files
committed
[ADD] dep example
1 parent 952a7e2 commit 8efce51

File tree

5 files changed

+232
-0
lines changed

5 files changed

+232
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13+
vendor/*

Gopkg.lock

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[prune]
29+
go-tests = true
30+
unused-packages = true
31+
32+

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main(){
6+
fmt.Println("hello")
7+
}

robot.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
// Command simple is a chromedp example demonstrating how to do a simple google
3+
// search.
4+
package main
5+
6+
import (
7+
"context"
8+
// "fmt"
9+
// "io/ioutil"
10+
"log"
11+
"time"
12+
13+
// "github.com/chromedp/cdproto/cdp"
14+
"github.com/chromedp/chromedp"
15+
)
16+
17+
func main() {
18+
var err error
19+
// create context
20+
ctxt, cancel := context.WithCancel(context.Background())
21+
defer cancel()
22+
23+
// create chrome instance
24+
c, err := chromedp.New(ctxt, chromedp.WithLog(log.Printf))
25+
if err != nil {
26+
log.Fatal(err)
27+
}
28+
29+
// run task list
30+
err = c.Run(ctxt, click())
31+
if err != nil {
32+
log.Fatal(err)
33+
}
34+
35+
// shutdown chrome
36+
err = c.Shutdown(ctxt)
37+
if err != nil {
38+
log.Fatal(err)
39+
}
40+
41+
// wait for chrome to finish
42+
err = c.Wait()
43+
if err != nil {
44+
log.Fatal(err)
45+
}
46+
47+
log.Printf("saved screenshot from search result listing `%s` (%s)", res, site)
48+
}
49+
50+
func googleSearch(q, text string, site, res *string) chromedp.Tasks {
51+
username := "stopkung"
52+
password := "Stop1234"
53+
return chromedp.Tasks{
54+
// Homepage and click link to login page
55+
chromedp.Navigate(`https://www.prakard.com/index.php`),
56+
chromedp.WaitVisible(`//*[@id="nav-main"]/li[10]/a`,chromedp.BySearch),
57+
chromedp.Click(`//*[@id="nav-main"]/li[10]/a`,chromedp.BySearch),
58+
// sign in
59+
chromedp.WaitVisible(`//*[@id="username"]`, chromedp.BySearch),
60+
chromedp.WaitVisible(`//*[@id="password"]`, chromedp.BySearch),
61+
// chromedp.WaitVisible(`//*[@id="login"]/div[1]/div/div/fieldset/dl[4]/dd/input[3]`, chromedp.BySearch),
62+
chromedp.SendKeys(`//*[@id="username"]`, username, chromedp.BySearch),
63+
chromedp.SendKeys(`//*[@id="password"]`, password, chromedp.BySearch),
64+
// chromedp.Click(`//*[@id="login"]/div[1]/div/div/fieldset/dl[4]/dd/input[3]`,chromedp.BySearch),
65+
66+
chromedp.Sleep(150 * time.Second),
67+
}
68+
}
69+
70+
// http://2captcha.com/in.php?key=19a8c698f9e041b93a2655787bab4360&method=userrecaptcha&googlekey=k=6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-&pageurl=https://www.google.com/recaptcha/api2/demo
71+
72+
// k=6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-

0 commit comments

Comments
 (0)