Wrapper around gimmeproxy - API compatible to http.Client
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
proxyfy.go

README.md

Proxyfy

Proxyfy Logo


Help me to grow this project:

Donate Button



Wrapper around gimmeproxy.com - API compatible to http.Client

With proxyfy you can simply add proxied requests to your go client.

It is as simple as changing http.Get("https://github.com") to proxyfy.Get("https://github.com"). From now on all the request get forwarded trough a random proxy.

For getting more than the 240 free request, please visit gimmeproxy.com and get yourself an API key. It's just a few bucks per month


Installation

Simply execute go get -u github.com/L1am0/proxyfy in your shell.

Usage

You have to setup proxyfy via an initalizer. There are two different ones available:

Simple

proxyfy := proxyfy.NewProxyfy(apiKey,schema string)

Here is already a part of the config set:

GimmeProxyConfig{
	ApiKey:         apiKey,
	Protocol:       scheme,
	MaxCheckPeriod: 30,
	Get:            true,
	Post:           true,
	SupportsHTTPS:  true,
	Referer:true,
	MinSpeed: 2000,
}

Advanced

proxyfy := NewProxyfyAdvancedConfig(gimmeConfig GimmeProxyConfig)

The gimmeConfig is defined via the following struct:

type GimmeProxyConfig struct {
	ApiKey         string
	Get            bool
	Post           bool
	Cookies        bool
	Referer        bool
	UserAgent      bool
	SupportsHTTPS  bool
	AnonymityLevel int
	Protocol       string
	Port           string
	Country        string
	MaxCheckPeriod int
	Websites       string
	MinSpeed       float64
	NotCountry     string
	IPPort         bool
	Curl           bool
}

For documentation on the different values visit: https://gimmeproxy.com/

Examples

[Basic] Use Proxyfys build in http.Client

Fire 30 GET requests and print the http response code

package main

import(
	"github.com/L1am0/proxyfy"
	"fmt"
)
func main() {
	proxyfy := proxyfy.NewProxyfy("", "http")

	for i := 0; i < 30; i++ {
		resp, err := proxyfy.Get("https://t3n.de")
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println(resp.StatusCode)
	}

}

[Advanced] GetRandomProxy

Use your own setup of a http.Client with Proxyfy providing you with a random proxy url

package main

import(
	"github.com/L1am0/proxyfy"
	"fmt"
	"net/http"
)
func main() {
	proxyfy := proxyfy.NewProxyfy("", "http")
	proxyURL := proxyfy.GetRandomProxy()

	transport := &http.Transport{
		Proxy: http.ProxyURL(proxyURL),
	}
	client := http.Client{
		Transport: transport,
	}

	req, err := http.NewRequest("GET", "https://t3n.de", nil) 
	if err != nil {
		fmt.Println(err)
		return
	}

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(resp.StatusCode)
}

Available Functions

GetAllProxys

GetAllProxys returns a slice containing all proxies that are available

func (c *Proxyfy) GetAllProxys() []*url.URL 

GetRandomProxy

GetRandomProxy returns a random *url.URL for usage with own http.Client

func (c *Proxyfy) GetRandomProxy() *url.URL

Do

Do executes the given *http.Request using a random proxy

func (c *Proxyfy) Do(req *http.Request) (resp *http.Response, err error)

Similar to http.Do()

Get

Get is a wrapper around Do(). Executes a GET request using a random proxy

func (c *Proxyfy) Get(url string) (resp *http.Response, err error)

Similar to http.Get()

Head

Head is a wrapper around Do(). Executes a HEAD request using a random proxy

func (c *Proxyfy) Head(url string) (resp *http.Response, err error) 

Similar to http.Head

Post

Post is a wrapper around Do(). Executes a POST request using a random proxy

func (c *Proxyfy) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

Similar to http.Post

PostForm

PostForm is a wrapper around Post(). Executes a Post request using a random proxy and sending data as x-www-form-urlencoded

func (c *Proxyfy) PostForm(url string, data url.Values) (resp *http.Response, err error) 

Similar to http.PostForm

NewProxyfyAdvancedConfig

NewProxyfyAdvancedConfig sets up proxyfy with an advanced configuration.

func NewProxyfyAdvancedConfig(gimmeConfig GimmeProxyConfig) *Proxyfy

Also have a look in the part Usage of this README

NewProxyfy

NewProxyfy sets up proxyfy with a minimal amount of input data

func NewProxyfy(apiKey, scheme string) *Proxyfy

Also have a look in the part Usage of this README


For getting more than the 240 free request, please visit gimmeproxy.com and get yourself an API key. It's just a few bucks per month

License

MIT License

Icons

Icons made by Smashicons from www.flaticon.com is licensed by CC 3.0 BY