https://github.com/j7mbo/gowebshareproxy
Simple SDK to make randomised proxy requests through proxy.webshare.io.
https://github.com/j7mbo/gowebshareproxy
Last synced: 3 months ago
JSON representation
Simple SDK to make randomised proxy requests through proxy.webshare.io.
- Host: GitHub
- URL: https://github.com/j7mbo/gowebshareproxy
- Owner: J7mbo
- License: mit
- Created: 2019-06-09T17:44:03.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-09T21:13:49.000Z (almost 6 years ago)
- Last Synced: 2025-02-06T05:22:03.809Z (4 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
gowebshareproxy
==[](https://godoc.org/github.com/j7mbo/gowebshareproxy)
[](LICENSE.md)Simple SDK to make requests through [proxy.webshare.io](https://proxy.webshare.io).
Make proxied requests by specifying the proxy you will go through or choose a random proxy if given a list.
### Basic Usage
1. Sign up for free [here](https://proxy.webshare.io/register/?referral_code=z3bbc9g2zzei).
2. Go to [proxy > list](https://proxy.webshare.io/proxy/list?type=username) and make a note of a proxy address, username
and password. You can also download the proxy list as a colon delimited text file if you want to do some stuff
programatically.
3. Do the following (add your own error checking):```go
package mainimport (
"net/http"
"net/url"
"github.com/j7mbo/gowebshareproxy"
)func main() {
// Input your proxy configuration here.
proxyUser := ""
proxyPass := ""
proxyUri, _ := url.Parse(":")
// Url to make proxied request to.
uri, _ := url.Parse("http://httpbin.org/get")
// Create your request as normal.
request, _ := http.NewRequest("GET", uri.String(), nil)
// Initialise gowebshareproxy.
proxy := gowebshareproxy.New(&http.Client{})// Make the proxied request.
res, err := proxy.Request(request, proxyUri, proxyUser, proxyPass)
}
```### Advanced Usage
You can use `Proxy.RequestWithRandomProxy` to choose a random proxy to perform a request through. From this call you
get back the response, any error as well as the chosen proxy url so you know which proxy you went through.On the [proxy > list](https://proxy.webshare.io/proxy/list?type=username) page you will find a button where you can
download your proxy list. It will have the following format:```text
x.x.x.x:80:username-123:password1
x.x.x.x:80:username-234:password2
x.x.x.x:80:username-345:password3
```Read in and parse this file into an `[]string`, and then use `Proxy.RequestWithRandomProxy`:
```go
file, _ := os.Open(path)
defer file.Close()var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}proxy := proxy.NewWithList(&http.Client{}, lines)
request, _ := http.NewRequest("GET", "http://httpbin.org/get", nil)
chosenProxy, res, err := proxy.RequestWithRandomProxy(request)
```Note that if you try and call `Proxy.RequestWithRandomProxy` without having initialised via `NewWithList` you will get
an error.