curl -x ***.tabproxy.vip:5000 -U "customer-USER:PASS" ipinfo.io
import json
import threading
import time
import requests as rq
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,* /*;q=0.8",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate, br"
}
testUrl = 'https://api.myip.la/en?json'
def testPost(host, port):
proxies = {
'http': 'http://{}:{}'.format(host, port),
'https': 'http://{}:{}'.format(host, port),
}
res = ""
while True:
try:
res = rq.get(testUrl, proxies=proxies, timeout=5)
print(res.status_code, "***", res.text)
break
except Exception as e:
print(e)
break
return
class ThreadFactory(threading.Thread):
def __init__(self, host, port):
threading.Thread.__init__(self)
self.host = host
self.port = port
def run(self):
testPost(self.host, self.port)
tiqu = 'Extract the link'
while 1 == 1:
resp = rq.get(url=tiqu, timeout=5)
try:
if resp.status_code == 200:
dataBean = json.loads(resp.text)
else:
print("failure")
time.sleep(1)
continue
except ValueError:
print("failure")
time.sleep(1)
continue
else:
print("code=", dataBean["code"])
code = dataBean["code"]
if code == 0:
threads = []
for proxy in dataBean["data"]:
threads.append(ThreadFactory(proxy["ip"], proxy["port"]))
for t in threads:
t.start()
time.sleep(0.01)
for t in threads:
t.join()
time.sleep(1)
#!/usr/bin/env node
require('request-promise')({
url: 'https://ipinfo.io',
proxy: 'http://ip:port',
})
.then(function(data){ console.log(data); },
function(err){ console.error(err); });
<?php
$targetUrl = "www.google.com";
$proxyServer = "http://{{ip}:{{domain}}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $targetUrl);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_PROXYTYPE, 0);
curl_setopt($ch, CURLOPT_PROXY, $proxyServer);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;)");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
var_dump($err);
var_dump($result);
package main
import (
"context"
"fmt"
"golang.org/x/net/proxy"
"io/ioutil"
"net"
"net/http"
"net/url"
"strings"
"time"
)
var testApi = "https://api.myip.la/en?json"
func main() {
getMyIp()
var proxyIP = "ip:port"
go httpProxy(proxyIP, "", "")
go Socks5Proxy(proxyIP, "", "")
time.Sleep(time.Minute)
}
func getMyIp() {
rsp, err := http.Get("https://api.myip.la/en?json")
if err != nil {
fmt.Println("Failed to get native IP", err.Error())
return
}
defer rsp.Body.Close()
body, err := ioutil.ReadAll(rsp.Body)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(time.Now().Format("2006-01-02 15:04:05 07"), "local ip:", string(body))
}
func httpProxy(proxyUrl, user, pass string) {
defer func() {
if err := recover(); err != nil {
fmt.Println(time.Now().Format("2006-01-02 15:04:05 07"), "http", "Return information:", err)
}
}()
urli := url.URL{}
if !strings.Contains(proxyUrl, "http") {
proxyUrl = fmt.Sprintf("http://%s", proxyUrl)
}
urlProxy, _ := urli.Parse(proxyUrl)
if user != "" && pass != "" {
urlProxy.User = url.UserPassword(user, pass)
}
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(urlProxy),
},
}
rqt, err := http.NewRequest("GET", testApi, nil)
if err != nil {
panic(err)
return
}
response, err := client.Do(rqt)
if err != nil {
panic(err)
return
}
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
fmt.Println(time.Now().Format("2006-01-02 15:04:05 07"), proxyUrl, "【http success】", "Return information:", response.Status, string(body))
return
}
func Socks5Proxy(proxyUrl, user, pass string) {
defer func() {
if err := recover(); err != nil {
fmt.Println(time.Now().Format("2006-01-02 15:04:05 07"), proxyUrl, " Return information:", err)
}
}()
var userAuth proxy.Auth
if user != "" && pass != "" {
userAuth.User = user
userAuth.Password = pass
}
dialer, err := proxy.SOCKS5("tcp", proxyUrl, &userAuth, proxy.Direct)
if err != nil {
panic(err)
}
httpClient := &http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (conn net.Conn, err error) {
return dialer.Dial(network, addr)
},
},
Timeout: time.Second * 10,
}
if resp, err := httpClient.Get(testApi); err != nil {
panic(err)
} else {
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(time.Now().Format("2006-01-02 15:04:05 07"), proxyUrl, "【socks5 success】", " Return information:", string(body))
}
}
package demo;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
class ApiProxyJava {
public static void main(String[] args) throws IOException {
testHttpWithOkHttp();
testSocks5WithOkHttp();
}
public static void testHttpWithOkHttp() throws IOException {
String url = "http://api.myip.la/en?json";
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("ip", 2000));
OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).build();
Request request = new Request.Builder().url(url).build();
okhttp3.Response response = client.newCall(request).execute();
String responseString = response.body().string();
System.out.println(responseString);
}
public static void testSocks5WithOkHttp() throws IOException {
String url = "http://api.myip.la/en?json";
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("ip", 8080));
OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).build();
Request request = new Request.Builder().url(url).build();
okhttp3.Response response = client.newCall(request).execute();
String responseString = response.body().string();
System.out.println(responseString);
}
}
#include "stdafx.h"
#include "curl/curl.h"
#pragma comment(lib, "libcurl.lib")
static size_t write_buff_data(char *buffer, size_t size, size_t nitems, void *outstream)
{
memcpy(outstream, buffer, nitems*size);
return nitems*size;
}
int GetUrlHTTP(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY,"http://host:port");
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "users:password");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L);
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK){
return res;
}else {
printf("error:%d\n", res);
MessageBox(NULL, TEXT("Get Ip Error"), TEXT("Help"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int GetUrlSocks5(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://host:port");
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "users:password");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L);
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK) {
return res;
}
else {
printf("error:%d\n", res);
MessageBox(NULL, TEXT("Get Ip Error"), TEXT("Help"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int GetUrl(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L);
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res == CURLE_OK)
{
return res;
}
else {
printf("error:%d\n", res);
MessageBox(NULL, TEXT("Get Ip Error"), TEXT("Help"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int main()
{
char *buff=(char*)malloc(1024*1024);
memset(buff, 0, 1024 * 1024);
GetUrl("http://ipinfo.io", buff);
printf("No Proxy:%s\n", buff);
memset(buff, 0, 1024 * 1024);
GetUrlHTTP("http://ipinfo.io", buff);
printf("Proxy By Http:%s\n", buff);
memset(buff, 0,1024 * 1024);
GetUrlSocks5("http://ipinfo.io", buff);
printf("Proxy by socks5:%s\n", buff);
Sleep(1000 * 1000);
free(buff);
return 0;
}