proxyfy

package module
v0.0.0-...-05df283 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2018 License: MIT Imports: 14 Imported by: 0

README

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

Documentation

Overview

Package proxyfy provides an api compatible http.Client for making requests All request are routed trough a random proxy provided by gimmeproxy.com For getting more requests visit https://a.paddle.com/v2/click/14088/32188?link=975

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GimmeProxyConfig

type GimmeProxyConfig struct {
	ApiKey         string  `url:"api_key,omitempty"`
	Get            bool    `url:"get,omitempty"`
	Post           bool    `url:"post,omitempty"`
	Cookies        bool    `url:"cookies,omitempty"`
	Referer        bool    `url:"referer,omitempty"`
	UserAgent      bool    `url:"user-agent,omitempty"`
	SupportsHTTPS  bool    `url:"supportsHttps,omitempty"`
	AnonymityLevel int     `url:"anonymityLevel,omitempty"`
	Protocol       string  `url:"protocol,omitempty"`
	Port           string  `url:"port,omitempty"`
	Country        string  `url:"country,omitempty"`
	MaxCheckPeriod int     `url:"maxCheckPeriod,omitempty"`
	Websites       string  `url:"websites,omitempty"`
	MinSpeed       float64 `url:"minSpeed,omitempty"`
	NotCountry     string  `url:"notCountry,omitempty"`
	IPPort         bool    `url:"ipPort,omitempty"`
	Curl           bool    `url:"curl,omitempty"`
}

type Proxyfy

type Proxyfy struct {
	// contains filtered or unexported fields
}

func NewProxyfy

func NewProxyfy(apiKey, scheme string) *Proxyfy

NewProxyfy sets up proxyfy with a minimal amount of input data It aready sets sane (in my eyes) defaults:

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

func NewProxyfyAdvancedConfig

func NewProxyfyAdvancedConfig(gimmeConfig GimmeProxyConfig) *Proxyfy

NewProxyfyAdvancedConfig sets up proxyfy with an advanced configuration. GimmeProxyConfig has following form (for documentation on the different values visit: https://gimmeproxy.com/#api)

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
}

func (*Proxyfy) Do

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

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

func (*Proxyfy) Get

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

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

func (*Proxyfy) GetAllProxys

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

GetAllProxys returns a slice containing all proxies that are in use

func (*Proxyfy) GetRandomProxy

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

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

func (*Proxyfy) Head

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

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

func (*Proxyfy) Post

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

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

func (*Proxyfy) PostForm

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL