Skip to content

Periodically fetch free proxies and maintain time to live for each ip port pair.

Notifications You must be signed in to change notification settings

HoMuChen/go-free-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-free-proxy

Periodically fetch free proxies in the background and maintain time to live for each ip port pair.

Usage

go get github.com/HoMuChen/go-free-proxy
package main

import (
    "fmt"
    "time"
    
    "github.com/HoMuChen/go-free-proxy"
)

func main() {
    //proxy.Options{TTL, Period} (seconds)
    proxyService := proxy.New(proxy.Options{10, 20})
    
    //Calling Run() will start to fetch proxies immediately and every {Period} seconds later.
    proxyService.Run()

    for {
        ip, err := proxyService.Random()
        //If no proxies is available, err will be errors.New("Empty list")
        if err != nil {
            fmt.Println(err)
        }

        fmt.Println(ip)

        time.Sleep(time.Second)
    }
}

About

Periodically fetch free proxies and maintain time to live for each ip port pair.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages