32 lines
786 B
Go
32 lines
786 B
Go
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)
|
|
//}
|
|
}
|