Example – Amazon Daily Deals

In the following example, we will use chrome-protocol and goquery to retrieve the Daily Deals from amazon.com. This example is a bit complex so the program has been broken into smaller chunks, which we will go through piece by piece. Let's begin with the package and import statements, as shown in the following code:

package mainimport (  "encoding/json"  "fmt"  "strings"  "time"  "github.com/4ydx/cdp/protocol/dom"  "github.com/4ydx/chrome-protocol"  "github.com/4ydx/chrome-protocol/actions"  "github.com/PuerkitoBio/goquery")

This block of code imports the necessary packages to run the rest of the program. Some new packages that we have not seen before are:

  • encoding/json: Go standard library for handling JSON data
  • github.com/4ydx/chrome-protocol ...

Get Go Web Scraping Quick Start Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.