January 2019
Beginner
132 pages
3h 14m
English
In Chapter 4, Parsing HTML, we used an example where we retrieved the titles and the prices of the latest releases from the Packt Publishing website. You could collect more information about each book by following each link to the book's main web page. In the following code example, we will add the navigation to make this possible:
package mainimport ( "fmt" "strings" "time" "github.com/PuerkitoBio/goquery")func main() { doc, err := goquery.NewDocument("https://www.packtpub.com/latest-releases") if err != nil { panic(err) } println("Here are the latest releases!") println("-----------------------------") time.Sleep(1 * time.Second) doc.Find(`div.landing-page-row div[itemtype$="/Product"] a`). Each(func(i int, e *goquery.Selection) ...Read now
Unlock full access