-
Notifications
You must be signed in to change notification settings - Fork 0
/
idea.go
66 lines (58 loc) · 1.3 KB
/
idea.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
59
60
61
62
63
64
65
66
package idea
import (
"github.com/PuerkitoBio/goquery"
"io/ioutil"
"sync"
//"io/ioutil"
"net/http"
)
type Idea struct {
One string
OneLength int
Two string
TwoLength int
Three string
ThreeLength int
}
func GetIdeaOne(code *Idea, wg *sync.WaitGroup) {
req ,_:=http.Get("http://www.lookdiv.com/code")
doc,_:=goquery.NewDocumentFromResponse(req)
text := doc.Find("textarea").Text()
code.One=text
code.OneLength= len([]byte(text))
defer wg.Done()
return
}
func IdeaList(code *Idea, wg *sync.WaitGroup) {
req ,_:=http.Get("https://shimo.im/docs/XvW3WpHgHdRHVXgV/read")
doc,_:=goquery.NewDocumentFromResponse(req)
doc.Find(".ql-sheet-cell p").Each(func(i int, selection *goquery.Selection) {
if i==0 {
code.Two = selection.Text()
code.TwoLength= len([]byte(selection.Text()))
}
if i==1 {
code.Three=selection.Text()
code.ThreeLength= len([]byte(selection.Text()))
}
})
defer wg.Done()
}
func GetIdeaTwo(code *Idea, wg *sync.WaitGroup) {
req,_:=http.Get("http://www.yanjie.site/jjj2.txt")
byte,_:=ioutil.ReadAll(req.Body)
codeString:=string(byte)
code.Two=codeString
defer wg.Done()
return
}
func GetAllIdea() *Idea {
var wg sync.WaitGroup
var idea Idea
wg.Add(2)
//go GetIdeaTwo(&idea,&wg)
go GetIdeaOne(&idea,&wg)
go IdeaList(&idea,&wg)
wg.Wait()
return &idea
}