{
"code":0,
"success":true,
"msg":"0",
"data":[
{"ip":"47.244.192.12","port":16098},
{"ip":"47.244.192.12","port":15698}
]
}
{
"code":0,
"success":true,
"msg":"0",
"data":[
{"ip":"47.244.192.12","port":16098},
{"ip":"47.244.192.12","port":15698}
]
}
生成API链接,调用HTTP GET请求即可返回所需的IP结果 * 可以直接按照以下格式组装所需的API链接:
可以直接按照以下格式组装所需的API 链接:http://api.proxy.ipidea.io/getProxyIp?num=100&return_type=txt&lb=1&sb=0&flow=1&regions=us&protocol=http
获取剩余流量接口: http://api.ownips.com/index/index/get_my_balance?neek=xxxx&appkey=xxxx
添加白名单接口: http://api.ownips.com/index/index/save_white?neek=xxxx&appkey=xxxx&white=您的ip
删除白名单接口: http://api.ownips.com/index/index/del_white?neek=xxxx&appkey=xxxx&white=您的ip
1、先下载解压,后续不要对文件夹做任何改动,否则将造成插件无法使用; mac不可直接双击解压(直接解压可能使解压后的文件不全) 使用命令行解压:Mac上zip,rar,tar文件命令解压和压缩。
2、打开chrome 的设置 -> 更多工具 -> 扩展程序或在Chrome地址栏,输入chrome://extensions/,回车打开拓展程序页面;
3、开启开发者模式,选择加载已解压的拓展程序,选中解压的文件夹地址栏边上出现全球logo即可。
4、填写账号密码登陆,选中记住密码后下次进来插件默认登陆该账号。
5、选择套餐类型、国家\地区等信息。
6、点击连接按钮立即获取IP;如没有当前流量点击立即购买择跳转官网获取更多流量。
实例:
// demo.cpp : 定义控制台应用程序的入口点。
//
#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;
}
/*
使用http代理
*/
int GetUrlHTTP(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY,"http://测试ip:端口");
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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
/*
使用socks5代理
*/
int GetUrlSocks5(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://测试ip:端口");
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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), 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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int main()
{
char *buff=(char*)malloc(1024*1024);
memset(buff, 0, 1024 * 1024);
GetUrl("http://baidu.com", buff);
printf("不使用代理:%s\n", buff);
memset(buff, 0, 1024 * 1024);
GetUrlHTTP("http://baidu.com", buff);
printf("http结果:%s\n", buff);
memset(buff, 0,1024 * 1024);
GetUrlSocks5("http://baidu.com", buff);
printf("socks5结果:%s\n", buff);
Sleep(1000 * 1000);
free(buff);
return 0;
}
实例:
package main
import (
"context"
"fmt"
"golang.org/x/net/proxy"
"io/ioutil"
"net"
"net/http"
"net/url"
"strings"
"time"
)
var testApi = " https://ipinfo.ownips.com"
func main() {
getMyIp()
//白名单代理
var proxyIP = "ip:port"
go httpProxy(proxyIP, "", "")
go Socks5Proxy(proxyIP, "", "")
time.Sleep(time.Minute)
}
func getMyIp() {
rsp, err := http.Get(" https://ipinfo.ownips.com")
if err != nil {
fmt.Println("获取本机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"), "本机ip:", string(body))
}
//http代理
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", "返回信息:", 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】", "返回信息:", response.Status, string(body))
return
}
//socks5代理
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, "返回信息:", 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】", "返回信息:", string(body))
}
}
实例:
#!/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 = "http://baidu.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); //http
// curl_setopt($ch, CURLOPT_PROXYTYPE, 5); //sock5
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 demo;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
/**
* compile 'com.squareup.okhttp3:okhttp:3.10.0'
*/
class ApiProxyJava {
public static void main(String[] args) throws IOException {
testHttpWithOkHttp();
testSocks5WithOkHttp();
}
public static void testHttpWithOkHttp() throws IOException {
String url = "https://ipinfo.ownips.com/n";
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 = "https://ipinfo.ownips.com/";
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);
}
}
实例:
# coding=utf-8
# !/usr/bin/env python
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://ipinfo.ownips.com'
# 核心业务
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)
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)
# 提取代理的链接 json类型的返回值
tiqu = '提取链接'
while 1 == 1:
# 每次提取10个,放入线程中
resp = rq.get(url=tiqu, timeout=5)
try:
if resp.status_code == 200:
dataBean = json.loads(resp.text)
else:
print("获取失败")
time.sleep(1)
continue
except ValueError:
print("获取失败")
time.sleep(1)
continue
else:
# 解析json数组
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()
# break
time.sleep(1)
实例:
from selenium import webdriver
import requests
def seleniumSetUP(ip,port):
# 设置Chrome驱动程序的路径
chromedriver_path = './chromedriver.exe'
# 创建Chrome浏览器实例
chrome_options = webdriver.ChromeOptions()
browser = webdriver.Chrome(chromedriver_path, chrome_options=chrome_options)
chrome_options.add_argument(f'--proxy-server=http://{ip}:{port}')
browser.get('http://ipinfo.io')
print(browser.page_source)
if __name__ == '__main__':
proxyUrl = "https://api-proxy.ownips.com/getIsp?num=9&type=1&lb=1&sb=0&flow=1®ions=&attribute=isp"
ipInfo = requests.get(porxyUrl)
info = ipInfo.json()["data"]
ip = info[0]["ip"]
port = info[0]["port"]
seleniumSetUP(ip,port)
实例:
// demo.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "curl/curl.h"
#pragma comment(lib, "libcurl.lib")
//curl 回调函数
static size_t write_buff_data(char *buffer, size_t size, size_t nitems, void *outstream)
{//把接收的数据拷贝到缓存中
memcpy(outstream, buffer, nitems*size);
return nitems*size;
}
/*
使用http代理
*/
int GetUrlHTTP(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY,"http://域名:端口");//设置http代理地址
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "用户名:密码");//代理用户名密码,以":"风格用户名以及密码
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);//设置读写缓存
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);//设置回调函数
curl_easy_setopt(curl, CURLOPT_URL, url);//设置url地址
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);//设置一个长整形数,控制多少秒传送CURLOPT_LOW_SPEED_LIMIT规定的字节数
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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
/*
使用socks5代理
*/
int GetUrlSocks5(char *url, char *buff)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://域名:端口");//设置socks5代理地址
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "用户名:密码");//代理用户名密码,以":"风格用户名以及密码
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff);//设置读写缓存
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff_data);//设置回调函数
curl_easy_setopt(curl, CURLOPT_URL, url);//设置url地址
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);//设置一个长整形数,控制多少秒传送CURLOPT_LOW_SPEED_LIMIT规定的字节数
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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
/*
不使用代理
*/
int GetUrl(char *url, char *buff)
{
CURL *curl;
CURLcode res;
//使用的curl库 初始化curl库
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);//设置url地址
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);//设置一个长整形数,控制多少秒传送CURLOPT_LOW_SPEED_LIMIT规定的字节数
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("错误代码:%d\n", res);
MessageBox(NULL, TEXT("获取IP错误"), TEXT("助手"), MB_ICONINFORMATION | MB_YESNO);
}
}
return res;
}
int main()
{
char *buff=(char*)malloc(1024*1024);
memset(buff, 0, 1024 * 1024);
//不使用http代理
GetUrl("http://ipinfo.io", buff);
printf("不使用代理:%s\n", buff);
//使用http代理
memset(buff, 0, 1024 * 1024);
GetUrlHTTP("http://ipinfo.io", buff);
printf("http结果:%s\n", buff);
//使用socks5代理
memset(buff, 0,1024 * 1024);
GetUrlSocks5("http://ipinfo.io", buff);
printf("socks5结果:%s\n", buff);
Sleep(1000 * 1000);
free(buff);
return 0;
}
实例:
package main
import (
"context"
"fmt"
"golang.org/x/net/proxy"
"io/ioutil"
"net"
"net/http"
"net/url"
"strings"
"time"
)
var testApi = "https://ipinfo.ownips.com/"
func main() {
getMyIp()
//账密
go httpProxy("ip:port", "账户", "密码")
go Socks5Proxy("ip:port", "账户", "密码")
time.Sleep(time.Minute)
}
func getMyIp() {
rsp, err := http.Get("https://ipinfo.ownips.com/")
if err != nil {
fmt.Println("获取本机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"), "本机ip:", string(body))
}
//http代理
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", "返回信息:", 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】", "返回信息:", response.Status, string(body))
return
}
//socks5代理
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, "返回信息:", 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】", "返回信息:", string(body))
}
}
实例:
#!/usr/bin/env node
require('request-promise')({
url: 'https://ipinfo.io',
proxy: 'http://[账户]:[密码]@[服务器ip]:2333',
})
.then(function(data){ console.log(data); },
function(err){ console.error(err); });
实例:
<?php
// 要访问的目标页面
$targetUrl = "http://baidu.com";
// 代理服务器
$proxyServer = "http://[服务器ip]:2333";
$proxyUserPwd = "{{user}}:{{psswd}}";
// 隧道身份信息
$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); //http
// curl_setopt($ch, CURLOPT_PROXYTYPE, 5); //sock5
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);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyUserPwd);
$result = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
var_dump($err);
var_dump($result);
实例:
package demo;
import okhttp3.Credentials;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
/**
* compile 'com.squareup.okhttp3:okhttp:3.10.0'
*/
class AutProxyJava {
public static void main(String[] args) throws IOException {
testWithOkHttp();
testSocks5WithOkHttp();
}
public static void testWithOkHttp() throws IOException {
String url = "https://ipinfo.ownips.com";
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("代理地址", 8080));
OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).proxyAuthenticator((route, response) -> {
String credential = Credentials.basic("账户", "密码");
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
}).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 = "https://ipinfo.ownips.com/";
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("代理地址", 8080));
java.net.Authenticator.setDefault(new java.net.Authenticator() {
private PasswordAuthentication authentication =
new PasswordAuthentication("账户", "密码".toCharArray());
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
});
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);
}
}
实例:
import _thread
import time
import requests
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60
MicroMessenger/6.5.19 NetType/4G Language/zh_TW",
}
mainUrl = 'https://ipinfo.ownips.com/'
def testUrl():
# 账密
entry = 'http://{}:{}@ip:port'.format("账户", "密码")
proxy = {
'http': entry,
'https': entry,
}
try:
res = requests.get(mainUrl, headers=headers, proxies=proxy, timeout=10)
print(res.status_code, res.text)
except Exception as e:
print("访问失败", e)
pass
for port in range(0, 10):
_thread.start_new_thread(testUrl, ())
time.sleep(0.1)
time.sleep(10)
实例:
# -*- coding: utf-8 -*-
import string
import zipfile
from selenium.webdriver import ChromeOptions
from selenium.webdriver import Chrome
import time
# 代理隧道验证信息(账号+密码)
proxyUser = ""
proxyPass = ""
proxyHost = ""
proxyPort = 2334
def create_proxy_auth_extension(proxy_host, proxy_port, proxy_username, proxy_password, scheme='http', plugin_path=None):
if plugin_path is None:
plugin_path = r'{}_{}@verification.zip'.format(proxy_username, proxy_password)
manifest_json = """
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Dobel Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"< all_urls >",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
"""
background_js = string.Template(
"""
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "${scheme}",
host: "${host}",
port: parseInt(${port})
},
bypassList: ["foobar.com"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "${username}",
password: "${password}"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["< all_urls >"]},
['blocking']
);
"""
).substitute(
host=proxy_host,
port=proxy_port,
username=proxy_username,
password=proxy_password,
scheme=scheme,
)
with zipfile.ZipFile(plugin_path, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js)
return plugin_path
chrome_options = ChromeOptions()
chrome_options.add_extension(create_proxy_auth_extension(proxyHost, proxyPort, proxyUser, proxyPass))
driver = Chrome(options=chrome_options)
# 要访问的目标页面
driver.get('url')
text = driver.page_source
print(text)
time.sleep(10)
driver.quit()
示例:直接下载 遇到问题?联系客服
实例:
Python selenium http/socks5:
#coding=utf-8
from selenium import webdriver
# 代理服务器
proxyHost = "ip"
proxyPort = "port"
proxyType='http' #socks5
# 代理隧道验证信息
service_args = [
"--proxy-type=%s" % proxyType,
"--proxy=%(host)s:%(port)s" % {
"host" : proxyHost,
"port" : proxyPort,
}
]
# 要访问的目标页面
targetUrl = "http://baidu.com"
driver = webdriver.PhantomJS(service_args=service_args)
driver.get(targetUrl)
print driver.title
print driver.page_source.encode("utf-8")
driver.quit()
示例:直接下载 遇到问题?联系客服
Phantomjs http/socks5: phantomjs --proxy=ip:port --proxy-type=[http|socks5|none] demo.js
不再提醒
不再提醒