guruguru

package module
v0.0.0-...-b3210f8 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 4 Imported by: 0

README

guruguru

Proxy-Rotatable HTTP(S) client.

Installation

$ go get github.com/dqn/guruguru

Usage

guruguru.Guruguru includes all http.Client properties and methods. Supports HTTP and SOCKS5 protocol for proxy.

package main

import (
  "fmt"
  "io/ioutil"
  "time"

  "github.com/dqn/guruguru"
)

func printIP(g *guruguru.Guruguru) {
  resp, _ := g.Get("https://ifconfig.me")
  defer resp.Body.Close()
  b, _ := ioutil.ReadAll(resp.Body)
  fmt.Println(string(b))
}

func main() {
  g := guruguru.New()

  g.UpdateProxies([]string{
    "http://XXX.XXX.XXX.XXX:8080",
    "socks5://YYY.YYY.YYY.YYY:7070",
  })
  g.RotateInterval = 10 * time.Second

  go g.StartRotateProxies()
  defer g.StopRotateProxies()

  printIP(g) // => XXX.XXX.XXX.XXX
  time.Sleep(10 * time.Second)
  printIP(g) // => YYY.YYY.YYY.YYY
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guruguru

type Guruguru struct {
	http.Client
	RotateInterval time.Duration
	Proxies        []url.URL
	// contains filtered or unexported fields
}

func New

func New() *Guruguru

func (*Guruguru) StartRotateProxies

func (g *Guruguru) StartRotateProxies()

func (*Guruguru) StopRotateProxies

func (g *Guruguru) StopRotateProxies()

func (*Guruguru) UpdateProxies

func (g *Guruguru) UpdateProxies(rawURLs []string) error

Jump to

Keyboard shortcuts

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