初始化
This commit is contained in:
31
cmd/main.go
Normal file
31
cmd/main.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"softdown.com/shusou/geziyor"
|
||||
"softdown.com/shusou/geziyor/client"
|
||||
"softdown.com/shusou/geziyor/export"
|
||||
)
|
||||
|
||||
func main() {
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
StartURLs: []string{"https://dytt.dytt8.net/index.htm"},
|
||||
Encoding: "gb2312",
|
||||
ParseFunc: quotesParse,
|
||||
Exporters: []export.Exporter{&export.JSON{}},
|
||||
}).Start()
|
||||
}
|
||||
|
||||
func quotesParse(g *geziyor.Geziyor, r *client.Response) {
|
||||
r.HTMLDoc.Find("div.co_content2 ul a").Each(func(i int, s *goquery.Selection) {
|
||||
//fmt.Println(s.Html())
|
||||
var url, _ = s.Attr("href")
|
||||
g.Exports <- map[string]interface{}{
|
||||
"title": s.Text(),
|
||||
"url": url,
|
||||
}
|
||||
})
|
||||
//if href, ok := r.HTMLDoc.Find("li.next > a").Attr("href"); ok {
|
||||
// g.Get(r.JoinURL(href), quotesParse)
|
||||
//}
|
||||
}
|
Reference in New Issue
Block a user