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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.