官术网_书友最值得收藏!

Go is simple

Beyond the architecture of the Go programming language itself, the standard library offers all the right packages you need to make web scraping easy. Go offers a built-in HTTP client in the net/http package that is fully-featured out of the box, but also allows for a lot of customization. Making an HTTP request is as simple, as follows:

http.Get("http://example.com")

Also a part of the net/http package are utilities to structure HTTP requests, HTTP responses, and all of the HTTP status codes, which we will dive into later in this book. You will rarely need any third-party packages to handle communication with web servers. The Go standard library also has tools to help analyze HTTP requests, quickly consume HTTP response bodies, and debug the requests and responses in your web scraper. The HTTP client in the net/http package is also very configurable, letting you tune special parameters and methods to suit your specific needs. This typically will not need to be done, but the option exists if you encounter such a situation.

This simplicity will help eliminate some of the guesswork of writing code. You will not need to determine the best way to make an HTTP request; Go has already worked it out and provided you with the best tools you need to get the job done. Even when you need more than just the standard library, the Go community has built tools that follow the same culture of simplicity. This certainly makes integrating third-party libraries an easy task. 

主站蜘蛛池模板: 华宁县| 璧山县| 青河县| 辽源市| 岫岩| 广东省| 巴青县| 汉寿县| 泾川县| 弥勒县| 谷城县| 梅河口市| 澳门| 武汉市| 隆昌县| 大余县| 缙云县| 亚东县| 响水县| 宜兰县| 绥阳县| 晴隆县| 沽源县| 宝应县| 舟山市| 余庆县| 永吉县| 山西省| 瑞昌市| 信宜市| 灵璧县| 株洲市| 海原县| 顺昌县| 淮阳县| 辛集市| 玉林市| 遂昌县| 友谊县| 旬阳县| 沁水县|