多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] > [github](https://github.com/PuerkitoBio/goquery) ## 安装 `go get github.com/PuerkitoBio/goquery` ## 实例 ### helloworld ``` package main import ( "fmt" "log" "github.com/PuerkitoBio/goquery" ) func ExampleScrape() { doc, err := goquery.NewDocument("http://metalsucks.net") if err != nil { log.Fatal(err) } // Find the review items doc.Find(".sidebar-reviews article .content-block").Each(func(i int, s *goquery.Selection) { // For each item found, get the band and title band := s.Find("a").Text() title := s.Find("i").Text() fmt.Printf("Review %d: %s - %s\n", i, band, title) }) } func main() { ExampleScrape() } ``` ## 获取`href`等属性 ``` url,bool := s.Find(".file-right a").Attr("href") ```