mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
First commit
This commit is contained in:
commit
8ffb773f43
2121 changed files with 1118910 additions and 0 deletions
30
vendor/github.com/PuerkitoBio/goquery/example_test.go
generated
vendored
Normal file
30
vendor/github.com/PuerkitoBio/goquery/example_test.go
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
package goquery_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
// This example scrapes the reviews shown on the home page of metalsucks.net.
|
||||
func Example() {
|
||||
// Load the HTML document
|
||||
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)
|
||||
})
|
||||
// To see the output of the Example while running the test suite (go test), simply
|
||||
// remove the leading "x" before Output on the next line. This will cause the
|
||||
// example to fail (all the "real" tests should pass).
|
||||
|
||||
// xOutput: voluntarily fail the Example output.
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue