Skip to main content
Go is a fantastic choice for building high-performance, concurrent web scrapers. Integrating 2extract.com proxies is straightforward using the standard library’s net/http package by configuring a custom http.Transport.

Basic Setup

The key to using a proxy with authentication in Go is to create a custom http.Client with a Transport that has its Proxy field set.
basic_setup.go

Real-World Example: Scraping Hacker News Headlines

Let’s build a simple but efficient Go application to scrape the titles of the top stories from the Hacker News homepage (news.ycombinator.com). This is a classic scraping target. This example demonstrates how to create a reusable function to perform the scraping, making it easy to adapt for other targets. We will target Hacker News as if we were in the United Kingdom (GB).
This example uses the goquery package for easy HTML parsing, similar to jQuery. Install it with: go get github.com/PuerkitoBio/goquery
hn_scraper.go

How to Run

  1. Make sure you have Go installed.
  2. Install the goquery package: go get github.com/PuerkitoBio/goquery
  3. Save the code as hn_scraper.go.
  4. Run from your terminal: go run hn_scraper.go

Expected Output

Terminal
This example shows how to structure a Go scraping application cleanly, separating the proxy client creation from the main scraping logic. This pattern can be easily extended for concurrent scraping using goroutines.