Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go Web Scraping Quick Start Guide

You're reading from   Go Web Scraping Quick Start Guide Implement the power of Go to scrape and crawl data from the web

Arrow left icon
Product type Paperback
Published in Jan 2019
Publisher Packt
ISBN-13 9781789615708
Length 132 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Vincent Smith Vincent Smith
Author Profile Icon Vincent Smith
Vincent Smith
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

What do HTTP requests/responses look like in Go?

Now that you are familiar with the basics of HTTP requests and responses, it's time to see what this looks like in Go. The standard library in Go provides a package named net/http, which contains all of the tools you will need to build a client that is capable of requesting pages from web servers and processing the responses with very little effort.

Let's take a look at the example from the beginning of this chapter, where we were accessing the web page at http://www.example.com/index.html. The underlying HTTP request instructs the web server at example.com to GET the index.html resource:

GET /index.html HTTP/1.1
Host: example.com

Using the Go net/http package, you would use the following line of code:

r, err := http.Get("http://www.example.com/index.html")
The Go programming language allows for multiple variables...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime