Library for working with proxy lists
go get github.com/NovikovRoman/proxylist/v3
Download proxy list:
p := proxylist.NewList()
bad, err := p.FromFile("proxylist.txt", proxylist.Ip4)
// or bad, err := p.FromFileIP4("filename")
if err != nil {
panic(err)
}
or
p := proxylist.NewList()
f, err := os.Open("proxylist.txt")
if err != nil {
panic(err)
}
bad, err := p.FromReader(f, proxylist.Ip4)
// or bad, err := p.FromReaderIP4(f)
if err != nil {
panic(err)
}
bad
- contains an array of invalid proxies (erroneous URL).
err
- error reading/opening file/io.Reader.
The loaded a list shuffled.
Get a free proxy:
resource := "site.com" // any resource name using a proxy
proxy := p.GetFreeIP4(resource)
// or proxy := p.GetFree(resource, proxylist.Ip4)
if proxy == nil {
panic("No free proxies.")
}
After using the proxy, you need to free it:
resource := "site.com" // any resource name using a proxy
p.SetFreeIP4(resource, proxy)
// or p.SetFree(resource, proxylist.Ip4)
Total number of proxies:
p.NumIP4()
// or p.Num(proxylist.Ip4)
Number of free proxies:
resource := "site.com" // any resource name using a proxy
p.NumFreeIP4(resource)
// or p.NumFree(resource, proxylist.Ip4)
Number of busy proxies:
resource := "site.com" // any resource name using a proxy
p.NumBusyIP4(resource)
// or p.NumBusy(resource, proxylist.Ip4)
go test -race -v
MIT License © Roman Novikov