Skip to content

Go SDK to proxy with a free IP pool based on FREE_PROXIES_LIST

Notifications You must be signed in to change notification settings

we-proxy/ip-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip-pool

See also: https://github.com/Zaeem20/FREE_PROXIES_LIST

Running Test

git clone git@github.com:we-proxy/ip-pool.git
cd ip-pool
# clone FREE_PROXIES_LIST to ./ (git-history too large, not recommended)
# git clone git@github.com/Zaeem20/FREE_PROXIES_LIST.git
# or download FREE_PROXIES_LIST (recommended)
mkdir FREE_PROXIES_LIST
curl https://fastly.jsdelivr.net/gh/Zaeem20/FREE_PROXIES_LIST@master/http.txt > FREE_PROXIES_LIST/http.txt
go test
>> ...
PASS
ok  	github.com/we-proxy/ip-pool	0.596s

Running Example

cd example
go run .
>> Response from proxy "http://135.181.154.225:80": {
  "ip": "135.181.154.225",
  "hostname": "repo.getlic.pro",
  "city": "Helsinki",
  "region": "Uusimaa",
  "country": "FI",
  "loc": "60.1695,24.9354",
  "org": "AS24940 Hetzner Online GmbH",
  "postal": "00100",
  "timezone": "Europe/Helsinki",
  "readme": "https://ipinfo.io/missingauth"
}

Import and Use

import ippool "github.com/we-proxy/ip-pool"
// ...
const random = true
const concurrent = 10
const eachTimeout = 10 * time.Second

func main() {
	// See: https://github.com/Zaeem20/FREE_PROXIES_LIST
	// proxies, err := ippool.Load("https", "path/to/https.txt") // 貌似全部阵亡
	proxies, err := ippool.Load("http", "path/to/http.txt")
	if err != nil {
		log.Println("Failed to load pool:", err)
		return
	}
	if random {
		ippool.Shuffle(proxies)
	}
	req, err := http.NewRequest("GET", "http://ipinfo.io", nil)
	if err != nil {
		log.Println("Failed to create request:", err)
		return
	}
	resp, proxy, err := ippool.Race(req, proxies, concurrent, eachTimeout)
	if err != nil {
		log.Println("Failed to proxy request:", err)
		return
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Println("Failed to read response:", err)
		return
	}
	log.Printf("Response from proxy %q: %s\n", proxy, string(res))
}

About

Go SDK to proxy with a free IP pool based on FREE_PROXIES_LIST

Topics

Resources

Stars

Watchers

Forks

Languages