Book Image

Go Web Scraping Quick Start Guide

By : Vincent Smith
Book Image

Go Web Scraping Quick Start Guide

By: Vincent Smith

Overview of this book

Web scraping is the process of extracting information from the web using various tools that perform scraping and crawling. Go is emerging as the language of choice for scraping using a variety of libraries. This book will quickly explain to you, how to scrape data data from various websites using Go libraries such as Colly and Goquery. The book starts with an introduction to the use cases of building a web scraper and the main features of the Go programming language, along with setting up a Go environment. It then moves on to HTTP requests and responses and talks about how Go handles them. You will also learn about a number of basic web scraping etiquettes. You will be taught how to navigate through a website, using a breadth-first and then a depth-first search, as well as find and follow links. You will get to know about the ways to track history in order to avoid loops and to protect your web scraper using proxies. Finally the book will cover the Go concurrency model, and how to run scrapers in parallel, along with large-scale distributed web scraping.
Table of Contents (10 chapters)

Following links

As you have seen in many examples throughout this book, there are HTML elements denoted by <a> tags that contain href attributes that reference different URLs. These tags, called anchor tags, are how links are generated on a web page. In a web browser, these links would typically have a different font color, often blue, with an underline. As a user in a web browser, if you wanted to follow a link, you would usually just click on it and you would be redirected to the URL. As a web scraper, the clicking action is usually not necessary. Instead, you can send a GET request to the URL in the href attribute itself.

If you find that the href attribute lacks the http:// or https:// prefix and the hostname, you must use the prefix and hostname of the current web page.

...