使用示例

1. 浏览器设置代理

电脑设置代理: 电脑设置代理上网

手机设置代理: Android手机设置代理上网

苹果设置代理: iPhone/iPad设置代理上网

2. 代理检测工具

代理猎手工具: proxyhunter_v3.1.zip

花刺代理工具: proxythorn_v1.8.zip

Proxifier工具: Proxifier_v3.28.zip(支持Socks4/5)

米扑检测(官方): http://proxy.mimvp.com/check.php

蚂蚁检测(国内): http://www.mayidaili.com/proxy/check-online/

代理检测(国内): http://www.kuaidaili.com/check/

代理检测(国内): http://www.xxorg.com/tools/checkproxy/

代理检测(国外): http://www.checker.freeproxy.ru/checker/

代理检测(国外): http://proxyipchecker.com/

代理测试(脚本)test_proxy.py(测试代理的成功率,连通时间等,python开发)

3. 代理编程示例

包含 Python、Java、PHP、C#、Go、Perl、Ruby、Shell 等十多种编程语言,已开源Github:mimvp-proxy-demo

使用代理,必须 IP + Port + http/https(socks4/5)协议 三个字段,一起配合使用(很多用户反馈代理无法使用原因在此)

提取代理,推荐第一次提取1000-5000个,第二次后每隔1分钟提取100个,因为代理检测需要时间(很多用户反馈提取代理有重复)

编程使用,请参考如下的编程示例;下载Python socks.py;客户反馈的常见问题,请参考整理的常见问题

使用代理时,遇到任何问题,欢迎您联系我们,客服QQ: 463103470

主流编程语言支持代理汇总表

(米扑代理原创,2017.07.30)

编程语言 后缀 HTTP HTTPS Socks4 Socks5
AutoHotkey .ahk Y - - -
C# .cs Y Y - -
Delphi .dpr Y - - -
Go .go Y - - Y
Groovy .groovy Y - - -
HTTPie .sh Y Y - -
Java .java Y Y Y Y
NodeJS .js Y Y Y Y
PhantomJS .js Y - - Y
Perl .pl Y Y - -
PHP .php Y Y Y Y
Python2 .py Y Y Y Y
Python3 .py Y Y Y Y
Python pyspide .py Y Y - -
Python requests .py Y Y Y Y
Python scrapy .py Y Y - -
Ruby .rb Y - - -
Selenium Java 示例 .java Y - - Y
Selenium Python .py Y - - Y
Shell .sh Y Y Y Y
易语言 .e Y - - -

AutohotKey 示例

; AutoHotkey 支持 http
;
; 米扑代理示例:
; http://proxy.mimvp.com/demo2.php
; 
; 米扑代理购买:
; http://proxy.mimvp.com
; 
; mimvp.com
; 2016-11-29
;
; AutoHotkey 安装与开发,请参考米扑博客,附有源代码:
; http://blog.mimvp.com/2017/09/autohotkey-an-zhuang-yu-kai-fa/
 

; ========== 代理设置方式1 ==========
URL := "http://proxy.mimvp.com/exist.php"
RESULT_FILE := "result_curl.txt"
MIMVP_PROXY := "138.68.165.154:3128"
 
Runcurl = curl.exe "%URL%" -x "%MIMVP_PROXY%" -o "%RESULT_FILE%"
;Runcurl = curl.exe "%URL%" -x user:password@proxyhost:port -o "%RESULT_FILE%"
Runwait, %comspec% /c %RunCurl%, , Hide



; ========== 代理设置方式2 ==========
MIMVP_PROXY_NOAUTH := 2
MIMVP_PROXY_AUTH := 1
 
;~ 代理服务器
MIMVP_PROXY := "138.68.165.154:3128"
 
;~ 要访问的目标页面
mimvp_url := "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
 
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.SetTimeouts(30000,30000,30000,30000)             ;~ Set timeouts to 30 seconds
 
whr.Open("GET", mimvp_url, true)
whr.SetRequestHeader("User-Agent", "curl/7.41.0")    ;~ 模拟curl的ua
 
 
;~ 设置代理服务器
whr.SetProxy(MIMVP_PROXY_NOAUTH, MIMVP_PROXY)
 
;~ 设置代理隧道验证信息
;whr.SetCredentials('mimvp-user', 'mimvp-pass', MIMVP_PROXY_AUTH)
 
whr.Send()
whr.WaitForResponse()
 
MsgBox % whr.ResponseText  ; 输入到消息框,网页内容太长则显示不完整
 
 
; 打开对话框选择文件,写入完整的网页内容
FileSelectFile, resultName, S16,, Create a new file:
if (resultName = "")
    return
     
outFile := FileOpen(resultName , "w" , "utf-8")
if !IsObject(outFile)
{
    MsgBox , 不能打开文件: %resultName%
    return
}
outFile.write(whr.ResponseText)
outFile.Close()
    

C# 示例

/**
C# 支持 http、https

米扑代理示例:
http://proxy.mimvp.com/demo2.php

米扑代理购买:
http://proxy.mimvp.com

mimvp.com
2015-11-09
*/
 
using System;
using System.IO;
using System.Net;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
    	// 代码级代理
        public static void Main(string[] args)
        {
            System.Net.WebProxy proxy = new WebProxy("218.21.230.156", 443);        // "107.150.96.188", 8080
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://proxy.mimvp.com/exist.php");
            request.Proxy = proxy;
            using (WebResponse response = request.GetResponse())
            {
                using (TextReader reader = new StreamReader(response.GetResponseStream()))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                        Console.WriteLine(line);
                }
            }
        }
 
 		// 系统变量级代理
        public static void Main2()
        {
            // your code goes here
            System.Net.WebProxy proxy = new WebProxy("107.150.96.188", 8080);
            System.Net.HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://proxy.mimvp.com/exist.php");
            req.Proxy = proxy;
            req.Timeout = 30 * 1000;
            System.Net.HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            Encoding bin = Encoding.GetEncoding("UTF-8");
            StreamReader reader = new StreamReader(resp.GetResponseStream(), bin);
            string str = reader.ReadToEnd();
            Console.WriteLine(str);
         
            reader.Close();
            reader.Dispose();
        }
    }
}
    

Delphi 示例

# Delphi 支持 http
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2016-11-25


interface
    uses
        Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
        Dialogs, StdCtrls, IDHTTP;

    type
        TForm1 = class(TForm)
            Button1: TButton;
            procedure Button1Click(Sender: TObject);
        private
            { Private declarations }
        public
            { Public declarations }
        end;

    var
        Form1: TForm1;

    implementation

    {$R * .dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    const
        // 要访问的目标页面
        mimvp_url = "http://proxy.mimvp.com/exist.php"
        mimvp_url2 = "https://proxy.mimvp.com/exist.php"
        mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"

        // 代理服务器
        proxy_ip = '138.68.165.154';
        proxy_port = 3128;
        
    var
        IDHTTP1 : TIDHTTP;
    begin
        Application.ProcessMessages;
        IDHTTP1 : = TIDHTTP.Create(nil);
        with IDHTTP1 do
        begin
            AllowCookies : = True;
            HandleRedirects : = True;
            ProxyParams.BasicAuthentication : = True;
            ProxyParams.ProxyServer : = proxy_ip;
            ProxyParams.ProxyPort : = proxy_port;
#             ProxyParams.ProxyUsername : = 'mimvp-user';
#             ProxyParams.ProxyPassword : = 'mimvp-pass';
            
            Request.Method : = 'GET';
            Request.Accept : = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8';
            Request.AcceptEncoding : = 'gzip, deflate, sdch';
            Request.AcceptLanguage : = 'zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4';
            Request.Connection : = 'keep-alive';
            Request.UserAgent : = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36';
            IDHTTP1.Get(mimvp_url);
        end;
    end;
end.   
    

Go 示例

/**
* go 支持 http、socks5
*
* 米扑代理示例:
* http://proxy.mimvp.com/demo2.php
*
* 米扑代理购买:
* http://proxy.mimvp.com
*
* mimvp.com
* 2017.6.20
*/

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"os"

	"golang.org/x/net/proxy"
)

// http(方法1)
func main_1(proxy_uri string, mimvp_url string) {
	proxy := func(_ *http.Request) (*url.URL, error) {
		return url.Parse(proxy_uri)
	}
	transport := &http.Transport{Proxy: proxy}
	client := &http.Client{Transport: transport}
	resp, err := client.Get(mimvp_url)
	if err != nil {
		fmt.Println("error : ", err)
		return
	} else {
		defer resp.Body.Close()
		body, _ := ioutil.ReadAll(resp.Body)
		fmt.Printf("%s\n", body)
	}
}



// http(方法2)
func main_2(proxy_uri string, mimvp_url string) {
	url_i := url.URL{}
	url_proxy, _ := url_i.Parse(proxy_uri)
	transport := &http.Transport{Proxy: http.ProxyURL(url_proxy)}
	client := http.Client{Transport: transport}
	resp, err := client.Get(mimvp_url)
	if err != nil {
		log.Fatalln(err)
	} else {
		defer resp.Body.Close()
		body, _ := ioutil.ReadAll(resp.Body)
		fmt.Printf("%s\n", body)
	}
}

// config environment varable
func main_22(proxy_uri string, mimvp_url string) {
	// url_i := url.URL{}
	// url_proxy, _ := url_i.Parse("https://127.0.0.1:9743")
	os.Setenv("HTTP_PROXY", "http://125.77.25.124:80")
	os.Setenv("HTTPS_PROXY", "https://210.209.89.100:8081")
	c := http.Client{ /* Transport: &http.Transport{ // Proxy: http.ProxyURL(url_proxy)} */ }
	resp, err := c.Get("http://mimvp.com")
	if err != nil {
		log.Fatalln(err)
	} else {
		defer resp.Body.Close()
		body, _ := ioutil.ReadAll(resp.Body)
		fmt.Printf("%s\n", body)
	}
}



// 指定代理ip
func getTransportFieldURL(proxy_addr *string) (transport *http.Transport) {
	url_i := url.URL{}
	url_proxy, _ := url_i.Parse(*proxy_addr)
	transport = &http.Transport{Proxy: http.ProxyURL(url_proxy)}
	return
}

// 从环境变量$http_proxy或$HTTP_PROXY中获取HTTP代理地址
// Linux 设置代理环境变量命令:
// http_proxy=http://125.77.25.124:80
// https_proxy=https://210.209.89.100:8081
func getTransportFromEnvironment() (transport *http.Transport) {
	transport = &http.Transport{Proxy: http.ProxyFromEnvironment}
	return
}

func fetch(mimvp_url, proxy_uri *string) (html string) {
	transport := getTransportFieldURL(proxy_uri)
	client := &http.Client{Transport: transport}
	req, err := http.NewRequest("GET", *mimvp_url, nil)
	req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
	if err != nil {
		log.Fatal(err.Error())
	}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err.Error())
	}
	if resp.StatusCode == 200 {
		robots, err := ioutil.ReadAll(resp.Body)
		resp.Body.Close()
		if err != nil {
			log.Fatal(err.Error())
		}
		html = string(robots)
	} else {
		html = ""
	}
	return
}

// http(方法3)
func main_3(proxy_uri string, mimvp_url string) {
	html := fetch(&mimvp_url, &proxy_uri)
	fmt.Println(html)
}



// socks5
// 1. download https://github.com/golang/net
// 2. unzip and move to /usr/local/go/src/golang.org/x/net/
// 3. import ( "golang.org/x/net/proxy" )
func main_socks5(proxy_socks string, mimvp_url string) {
	dialer, err := proxy.SOCKS5("tcp", proxy_socks, nil, proxy.Direct)
	if err != nil {
		fmt.Println(os.Stderr, "can't connect to socks5 proxy:", err)
		os.Exit(1)
	}

	// setup a http client
	//	transport := &http.Transport{}
	//	transport.Dial = dialer.Dial
	transport := &http.Transport{Dial: dialer.Dial}
	client := &http.Client{Transport: transport}

	resp, err := client.Get(mimvp_url)
	if err != nil {
		log.Fatalln(err)
	} else {
		defer resp.Body.Close()
		body, _ := ioutil.ReadAll(resp.Body)
		fmt.Printf("%s\n", body)
	}
}


func main() {
	// http
	proxy_uri := "http://125.77.25.124:80"
	mimvp_url := "http://proxy.mimvp.com/exist.php"
	main_1(proxy_uri, mimvp_url)
	main_2(proxy_uri, mimvp_url)
	main_3(proxy_uri, mimvp_url)

	// socks5
	proxy_socks := "175.138.65.244:1080"
	main_socks5(proxy_socks, mimvp_url)
}

// 执行命令:
// $ go build mimvp-proxy-go.go
// $ ./mimvp-proxy-go
    

Groovy 示例

/**
 * Groovy 支持 http
 *
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 *
 * 米扑代理购买:
 * http://proxy.mimvp.com
 *
 * mimvp.com
 * 2017-07-18
 * 
 * Groovy 爬取网页示例:
 * http://blog.mimvp.com/2017/09/groovy-tong-guo-dai-li-zhua-qu-wang-ye/
 */

 
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1' )

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
import org.apache.http.auth.*


class MimvpSpider {
	static def proxy_http = "http://208.92.93.218:1080"
	
	static def mimvp_url = "http://proxy.mimvp.com/exist.php"
	static def mimvp_url2 = "https://proxy.mimvp.com/exist.php"
	

	static main(args) {
		spider_proxy(MimvpSpider.mimvp_url, MimvpSpider.proxy_http)		// http
		spider_proxy(MimvpSpider.mimvp_url2, MimvpSpider.proxy_http)	// https
	}


	static spider_proxy(mimvp_url, proxy) {
		def http = new HTTPBuilder(mimvp_url)

//		http.client.getCredentialsProvider().setCredentials(
//		    new AuthScope("myproxy.com", 8080),
//		    new UsernamePasswordCredentials("proxy-username", "proxy-password")
//		)
		
		def proxy_type = proxy.split("://")[0]
		def proxy_ip = proxy.split("://")[1].split(":")[0]
		def proxy_port = proxy.split("://")[1].split(":")[1]
		proxy_port = proxy_port.toInteger()
		
		println proxy_type
		println proxy_ip
		println proxy_port
		
		
//		http.setProxy('myproxy.com', 8080, 'http')
		http.setProxy(proxy_ip, proxy_port, proxy_type)
		http.ignoreSSLIssues()		// 访问https网站,不需验证, module='http-builder', version='0.7.1'

		http.request( GET, TEXT ){ req ->
			response.success = { resp, reader ->
				println "Response: ${reader.text}"
			}
		}
	}
}
    

HTTPie 示例

#!/bin/bash
#
# http 支持 http、https
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
#
# 米扑代理购买:
# http://proxy.mimvp.com
#
# mimvp.com
# 2015-11-10


# http代理格式 		--proxy http:IP:Port
# https代理格式 		--proxy https:IP:Port


$ http --help
usage: http [--json] [--form] [--pretty {all,colors,format,none}]
            [--style STYLE] [--print WHAT] [--headers] [--body] [--verbose]
            [--all] [--history-print WHAT] [--stream] [--output FILE]
            [--download] [--continue]
            [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
            [--auth USER[:PASS]] [--auth-type {basic,digest}]
            [--proxy PROTOCOL:PROXY_URL] [--follow]
            [--max-redirects MAX_REDIRECTS] [--timeout SECONDS]
            [--check-status] [--verify VERIFY]
            [--ssl {ssl2.3,ssl3,tls1,tls1.1,tls1.2}] [--cert CERT]
            [--cert-key CERT_KEY] [--ignore-stdin] [--help] [--version]
            [--traceback] [--default-scheme DEFAULT_SCHEME] [--debug]
            [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
            
# http
http --proxy "http:217.107.197.174:8081" http://proxy.mimvp.com/exist.php

# https
http --verify no --proxy "https:46.105.214.133:3128" https://proxy.mimvp.com/exist.php
    

Java 示例

/**
 * Java 支持 http、https、socks4、socks5
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2015-11-09
 */


package com.mimvp;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;


public class MimvpProxyJava {

	@SuppressWarnings({ "serial" })
	public static HashMap proxyMap = new HashMap() {
		{
			put("http", "138.68.161.14:3128");
			put("https", "104.236.120.183:8080");
			put("socks4", "113.7.118.112:2346");
			put("socks5", "61.135.155.82:1080");
		}
	};
	
	final static String proxyUrl = "http://proxy.mimvp.com/exist.php";
	final static String proxyUrl2 = "https://proxy.mimvp.com/exist.php";
	final static String proxyUrl3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js";
	

	// 全局禁止ssl证书验证,防止访问非验证的https网址无法访问,例如:https://mimvp.com
	static {
	    disableSslVerification();
	}

	private static void disableSslVerification() {
	    try
	    {
	        // Create a trust manager that does not validate certificate chains
	        TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
	            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
	                return null;
	            }
	            public void checkClientTrusted(X509Certificate[] certs, String authType) {
	            }
	            public void checkServerTrusted(X509Certificate[] certs, String authType) {
	            }
	        }
	        };

	        // Install the all-trusting trust manager
	        SSLContext sc = SSLContext.getInstance("SSL");
	        sc.init(null, trustAllCerts, new java.security.SecureRandom());
	        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

	        // Create all-trusting host name verifier
	        HostnameVerifier allHostsValid = new HostnameVerifier() {
	            public boolean verify(String hostname, SSLSession session) {
	                return true;
	            }
	        };

	        // Install the all-trusting host verifier
	        HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
	    } catch (NoSuchAlgorithmException e) {
	        e.printStackTrace();
	    } catch (KeyManagementException e) {
	        e.printStackTrace();
	    }
	}
	
	
	public static void main(String args[]){
		int dataLen = 0;

		// proxy protocol 只支持 http、socks5
		System.out.println("+++++++++ proxy protocol +++++++++");			
		Iterator it = MimvpProxyJava.proxyMap.keySet().iterator();
		while(it.hasNext()){
			String proxyType = it.next();
			String proxyStr = MimvpProxyJava.proxyMap.get(proxyType);
			dataLen = proxy_protocol(proxyType, proxyStr);
			System.out.println(proxyType + " : " + proxyStr + " --> " + dataLen);
		}

		// proxy property 支持http、https、socks4、socks5
		System.out.println("\n+++++++++ proxy property +++++++++");
		Iterator it2 = MimvpProxyJava.proxyMap.keySet().iterator();
		while(it2.hasNext()){
			String proxyType = it2.next();
			String proxyStr = MimvpProxyJava.proxyMap.get(proxyType);
			dataLen = proxy_property(proxyType, proxyStr);
			System.out.println(proxyType + " : " + proxyStr + " --> " + dataLen);
		}

		// proxy socks
		System.out.println("\n++++++++ proxy socks +++++++++++");
		Iterator it3 = MimvpProxyJava.proxyMap.keySet().iterator();
		while(it3.hasNext()){
			String proxyType = it3.next();
			String proxyStr = MimvpProxyJava.proxyMap.get(proxyType);
			dataLen = proxy_socks(proxyType, proxyStr);
			System.out.println(proxyType + " : " + proxyStr + " --> " + dataLen);
		}
	}
	
	
	// 设置系统代理,支持全部协议 http,https,socks4,socks5
	private static int proxy_property(String proxyType, String proxyStr) {
		int dataLen = 0;

		String proxy_ip = proxyStr.split(":")[0];
		String proxy_port = proxyStr.split(":")[1];
		
		Properties prop = System.getProperties();
		
		// http
		if(proxyType.equals("http")){
			prop.setProperty("http.proxySet", "true");
			prop.setProperty("http.proxyHost", proxy_ip);
			prop.setProperty("http.proxyPort", proxy_port);
			prop.setProperty("http.nonProxyHosts", "localhost|192.168.0.*");
		}
		
		// https
		if (proxyType.equals("https")) {
			prop.setProperty("https.proxyHost", proxy_ip);
			prop.setProperty("https.proxyPort", proxy_port);
		}
        
        // socks
		if(proxyType.equals("socks4") || proxyType.equals("socks5")){
	        prop.setProperty("socksProxySet", "true");
	        prop.setProperty("socksProxyHost", proxy_ip);
	        prop.setProperty("socksProxyPort", proxy_port);
		}
        
        // ftp
		if(proxyType.equals("ftp")){
	        prop.setProperty("ftp.proxyHost", proxy_ip);
	        prop.setProperty("ftp.proxyPort", proxy_port);
	        prop.setProperty("ftp.nonProxyHosts", "localhost|192.168.0.*");
		}
        
//        // auth 设置登录代理服务器的用户名和密码
//        Authenticator.setDefault(new MyAuthenticator("user", "pwd"));
        
		try{
			URL url = new URL(proxyUrl2);		// http://proxy.mimvp.com
			URLConnection conn = url.openConnection();
			conn.setConnectTimeout(30 * 1000);
			
			InputStream in = conn.getInputStream();
			InputStreamReader reader = new InputStreamReader(in);
			char[] ch = new char[1024];
			int len = 0;
			String data = "";
			while((len = reader.read(ch)) > 0) {
				String newData = new String(ch, 0, len);
				data += newData;
			}
			System.out.println("data : " + data);
			dataLen = data.length();
			
		} catch(Exception e) {
			e.printStackTrace();
		}
        return dataLen;
	}
	
	static class MyAuthenticator extends Authenticator {
        private String user = "";
        private String password = "";
        public MyAuthenticator(String user, String password) {
            this.user = user;
            this.password = password;
        }
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(user, password.toCharArray());
        }
    }
	
	
	// 使用函数协议,仅支持 HTTP 和 SOCKS5
	private static int proxy_protocol(String proxyType, String proxyStr){
		int dataLen = 0;

		String proxy_ip = proxyStr.split(":")[0];
		int proxy_port = Integer.parseInt(proxyStr.split(":")[1]);
		
		try{
			URL url = new URL(proxyUrl);		// http://proxy.mimvp.com
			
			InetSocketAddress addr = new InetSocketAddress(proxy_ip, proxy_port);
			Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
			if(proxyType.equals("socks4") || proxyType.equals("socks5")) {
				proxy = new Proxy(Proxy.Type.SOCKS, addr);
			}
			
			URLConnection conn = url.openConnection(proxy);
			conn.setConnectTimeout(30 * 1000);
			
			InputStream in = conn.getInputStream();
			InputStreamReader reader = new InputStreamReader(in);
			char[] ch = new char[1024];
			int len = 0;
			String data = "";
			while((len = reader.read(ch)) > 0) {
				String newData = new String(ch, 0, len);
				data += newData;
			}
			System.out.println("data : " + data);
			dataLen = data.length();
			
		} catch(Exception e) {
			e.printStackTrace();
		}
		return dataLen;
	}
	
	
	// proxy socket,测试用
	private static int proxy_socks(String proxyType, String proxyStr){
		int dataLen = 0;
		Socket socket = null;
		
		String proxy_ip = proxyStr.split(":")[0];
		int proxy_port = Integer.parseInt(proxyStr.split(":")[1]);
		
		try {
			socket = new Socket(proxy_ip, proxy_port);
			
			byte[] ch = new String("GET http://www.mimvp.com/ HTTP/1.1\r\n\r\n").getBytes();
			socket.getOutputStream().write(ch);
			socket.setSoTimeout(30 * 1000);
			
			byte[] bt = new byte[1024];
			InputStream in = socket.getInputStream();
			int len = 0;
			String data = "";
			while((len = in.read(bt)) > 0) {
				String newData = new String(bt, 0, len);
				data += newData;
			}
			System.out.println("data : " + data);
			dataLen = data.length();
		}catch(Exception e) {
			e.printStackTrace();
		} finally{
			try {
				if(socket != null){
					socket.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			socket = null;
		}
		return dataLen;
	}
	
	
//	启动运用通过JVM参数走代理, 注意这种代理是全局的,设置以后全部会自动走代理,
//	如果需要单个请求走代理(在走代理失败的话, 会自动尝试本地直接访问), 请使用proxy_protocol()协议代理函数
//	-DproxySet=true
//	-Dhttp.proxyHost=proxyIp
//	-Dhttp.proxyPort=proxyPort

}
    

NodeJS 示例

/**
 * NodeJS 支持 http、https、socks4、socks5
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2017.5.25
 * 
 * 米扑博客示例详解 : 
 * http://blog.mimvp.com/2017/10/node-js-she-zhi-dai-li-de-liang-zhong-fang-shi-superagent-proxy-he-https-proxy-agent/
 * 
 * proxy-agent		 : https://www.npmjs.com/package/proxy-agent
 * superagent-proxy  : https://www.npmjs.com/package/superagent-proxy
 * http-proxy-agent  : https://www.npmjs.com/package/http-proxy-agent
 * https-proxy-agent : https://www.npmjs.com/package/https-proxy-agent
 * socks-proxy-agent : https://www.npmjs.com/package/socks-proxy-agent
 */

var proxy_http = "http://35.154.138.213:80";
var proxy_https = "http://103.247.154.105:8080";	
var proxy_socks4 = "socks4://202.159.8.243:1080";
var proxy_socks5 = "socks5://94.177.216.47:2016";

var mimvp_url = "http://proxy.mimvp.com/exist.php";
var mimvp_url2 = "https://proxy.mimvp.com/exist.php";
var mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js";



//http for http
function check_http(proxy_uri, mimvp_url) {
	var http = require('http');
	var url = require('url');
	
	console.log("proxy_uri : " + proxy_uri);
	
	var proxy_ip = proxy_uri.toString().split("://")[1].split(":")[0];		// IP
	var proxy_port = proxy_uri.toString().split("://")[1].split(":")[1];	// Port
	
	const options = {
		      host     : proxy_ip,
		      port     : proxy_port,
		      path     : mimvp_url,
		      method   : 'GET',
		      headers : {
		    	  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
		    	  "Host": "apps.bdimg.com",
		    	  "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
		      }
	};
	
	http
    .request(options, function(res) {
        console.log("got response code: " + res.statusCode);
        if (res.statusCode == 200) {
            res.setEncoding("utf-8");
            var resData = "";
            res.on("data", function(chunk) {
                resData += chunk;
            }).on("end", function() {
                console.log("got response text: " + resData);
            });
        } else {
            console.log("res.statusCode err " + res.statusCode);	// 请求失败
        }
    })
    .on("error", function(err) {
        console.log(err);
    })
    .end();   
};


// request http, https
function check_request(proxy_uri, mimvp_url) {
	var request = require('request');
	
	console.log("proxy_uri : " + proxy_uri);
	
	const proxiedRequest = request.defaults({'proxy': proxy_uri});
	const options = {
		      url     : mimvp_url,
		      headers : {
		    	  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
		    	  "Host": "apps.bdimg.com",
		    	  "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
		      }
	};
	
	proxiedRequest
    .get(options, function (err, res, body) {
        console.log("got response: " + res.statusCode);
        console.log("got body: " + body);
    })
    .on("error", function (err) {
        console.log(err);
    });          
};


// superagent-proxy http, https
function check_superagent(proxy_uri, mimvp_url) {
	var superagent = require('superagent');
	require('superagent-proxy')(superagent);
	
	console.log("proxy_uri : " + proxy_uri);
	
	superagent
	.get(mimvp_url)
	.proxy(proxy_uri)
	.buffer(true)
	.set('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36')
	.set('Host','apps.bdimg.com')
	.set('Accept','text/html,application/xhtml+xml,application/xml,application/x-javascript;q=0.9,image/webp,image/apng,*/*;q=0.8')
	.set('Accept-Encoding','gzip, deflate, br')
	.end(function onResponse(err, res) {
		if (err) {
			console.log(err);
		} else {
			console.log(res.status, res.headers);
			console.log(res.text);
		}
	});
};


// https-proxy-agent https
function check_httpsproxyagent(proxy_uri, mimvp_url) {
	var url = require('url');
	var https = require('https');
	var HttpsProxyAgent = require('https-proxy-agent');
	 
	console.log('using proxy server %j', proxy_uri);	// 'https://79.137.80.210:3128'
	
	var agent = new HttpsProxyAgent(proxy_uri);
	var endpoint = process.argv[2] || mimvp_url;
	var options = url.parse(endpoint);
	options.agent = agent;
	options.port = 443;
	options.secureProxy = true;
	
	headers = {
	"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
	"Host": "apps.bdimg.com",
	"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
	};
	options.headers = headers;
	console.log('options %j', options);
	 
	https.get(options, function (res) {
	  console.log('"response" event!', res.headers);
	  res.pipe(process.stdout);
	});
}


//socks-proxy-agent socks4, socks5
function check_socksproxyagent(proxy_uri, mimvp_url) {
	var url = require('url');
	var http = require('http');
	var SocksProxyAgent = require('socks-proxy-agent');
	 
	console.log('using proxy server %j', proxy_uri);	// 'socks://94.177.216.47:2016'
	
	var agent = new SocksProxyAgent(proxy_uri);
	var endpoint = process.argv[2] || mimvp_url;
	var options = url.parse(endpoint);
	options.agent = agent;
	options.port = 443;
	options.secureProxy = true;
	
	headers = {
	"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
	"Host": "apps.bdimg.com",
	"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
	"Accept-Encoding": "gzip, deflate, br",
	};
	options.headers = headers;
	console.log('options %j', options);
	 
	http.get(options, function (res) {
	  console.log('"response" event!', res.headers);
	  res.pipe(process.stdout);
	});
}

// http
check_http(proxy_http, mimvp_url);					// http

// request
check_request(proxy_http, mimvp_url);				// http
check_request(proxy_https, mimvp_url3);				// https

// superagent
check_superagent(proxy_http, mimvp_url);			// http
check_superagent(proxy_https, mimvp_url3);			// https

// https_proxy_agent
check_httpsproxyagent(proxy_https, mimvp_url3);		// https

// socks_proxy_agent
check_socksproxyagent(proxy_socks4, mimvp_url);		// socks4
check_socksproxyagent(proxy_socks5, mimvp_url);		// socks5


// 执行命令:
// cd /usr/local/node/lib/node_modules/npm/
// sudo cp ~/Documents/workspace/MimvpProxyDemo/NodeJS/mimvp-proxy-nodejs.js .
// sudo node mimvp-proxy-nodejs.js
    

PhantomJS 示例

/**
 * PhantomJS 支持 http、socks5
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2017.5.22
 */

// http代理格式	:	phantomjs --proxy-type=http --proxy=IP:Port
// socks代理格式	:	phantomjs --proxy-type=socks5 --proxy=IP:Port


/**
 $ phantomjs -h  
 --ignore-ssl-errors=            Ignores SSL errors (expired/self-signed certificate errors): 'true' or 'false' (default)
 --proxy=                        Sets the proxy server, e.g. '--proxy=http://proxy.company.com:8080'
 --proxy-auth=                   Provides authentication information for the proxy, e.g. ''-proxy-auth=username:password'
 --proxy-type=                   Specifies the proxy type, 'http' (default), 'none' (disable completely), or 'socks5'
 --script-encoding=              Sets the encoding used for the starting script, default is 'utf8'
 --web-security=                 Enables web security, 'true' (default) or 'false'
 --ssl-protocol=                 Selects a specific SSL protocol version to offer.
 --ssl-ciphers=                  Sets supported TLS/SSL ciphers. 
 --ssl-certificates-path=        Sets the location for custom CA certificates 
 --ssl-client-certificate-file=  Sets the location of a client certificate
 --ssl-client-key-file=          Sets the location of a clients' private key
 --ssl-client-key-passphrase=    Sets the passphrase for the clients' private key
 */


var mimvp_url = "http://proxy.mimvp.com/exist.php";
var mimvp_url2 = "https://proxy.mimvp.com/exist.php";
var mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js";

var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36';

page.open(mimvp_url, {}, function(status) { 		// http
//page.open(mimvp_url2, {}, function(status) { 		// socks5
	console.log('status : ' + status);
	if (status == "success") {
		console.log("set proxy success");
		console.log('page.content : ' + page.content);
		console.log('page.content length : ' + page.content.length);
	} else {
		console.log("set proxy fail");
	}
	phantom.exit();
});

// 执行命令:
// http    : phantomjs --proxy-type=http --proxy=23.94.65.132:1080 mimvp-proxy-phantomjs.js
// socks5  : phantomjs --proxy-type=socks5 --proxy=78.63.194.59:35844 --ignore-ssl-errors=true mimvp-proxy-phantomjs.js
    

Perl 示例

#!/usr/bin/env perl 
#
# Perl 支持 http、https
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2017-03-28


use CGI;
use strict;
use LWP::UserAgent;


our %proxy_http = ("http", "http://138.68.165.154:3128");
our %proxy_https = ("https", "https://113.106.94.213:80");
our %proxy_connect = ("https", "connect://173.233.55.118:443");

our $mimvp_url = "http://proxy.mimvp.com/exist.php";
our $mimvp_url2 = "https://proxy.mimvp.com/exist.php";



## http 
sub test_http {
	my ($url, %proxy) = @_;
	
	print "proxy  : $proxy{'http'}\n";
	print "https  : $proxy{'https'}\n";
	print "url : $url\n";
	
	my $browser = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
	$browser->env_proxy();
	
# 	# 设置的代理格式
# 	$browser->proxy('http', 'http://138.68.165.154:3128');  
# 	$browser->proxy(['http','ftp'], 'http://138.68.165.154:3128');  
	$browser->proxy(%proxy);
	$browser->timeout(30);
	$browser->agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36');
	
	my $response = $browser->get($url);  				# 爬取的网址
	my $is_success = $response->is_success();			# 1
	my $content_type = $response->content_type();		# text/html
	my $content = $response->content();					# 网页正文
	my $content_length = length($content);				# 网页正文长度
	
	print "$is_success\n";
	print "$content_type\n";
	print "$content_length\n";
	print "$content\n";
}



## https (NO Success)
## error info : LWP::Protocol::https::Socket: SSL connect attempt failed because of handshake problems SSL wants a read first at /System/Library/Perl/Extras/5.18/LWP/Protocol/http.pm line 51.
sub test_https {
	my ($url, %proxy) = @_;
	
	print "proxy  : $proxy{'http'}\n";
	print "https  : $proxy{'https'}\n";
	print "url : $url\n";
	
	BEGIN {
		$ENV{HTTPS_PROXY} = 'https://173.233.55.118:443'; 
# 		$ENV{HTTPS_PROXY_USERNAME} = ; 
# 		$ENV{HTTPS_PROXY_PASSWORD} = ; 
		$ENV{HTTPS_DEBUG} = 1;
		$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
	}
	
	my $browser = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
	$browser->env_proxy();
	
# 	# 设置的代理格式
# 	$browser->proxy(%proxy);	# NO USE
	$browser->timeout(30);
	$browser->agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36');
	
	my $req = new HTTP::Request('GET', $url);			# 爬取的网址
	my $response = $browser->request($req);
	
	my $is_success = $response->is_success();			# 1
	my $content_type = $response->content_type();		# text/html
	my $content = $response->content();					# 网页正文
	my $content_length = length($content);				# 网页正文长度
	
	print "$is_success\n";
	print "$content_type\n";
	print "$content_length\n";
	print "$content\n";
}



## https (connect)
## 1. download LWP-Protocol-connect (wget http://search.cpan.org/CPAN/authors/id/B/BE/BENNING/LWP-Protocol-connect-6.09.tar.gz)
## 2. tar zxvf LWP-Protocol-connect-6.09.tar.gz 
##    cd LWP-Protocol-connect-6.09
##    perl Makefile.PL
##    make
##    sudo make install
sub test_connect {
	my ($url, %proxy) = @_;
	
	print "proxy  : $proxy{'http'}\n";
	print "https  : $proxy{'https'}\n";
	print "url : $url\n";
	
	my $browser = LWP::UserAgent->new();
	$browser->env_proxy();
	
# 	# 设置的代理格式
# 	$browser->proxy('https', 'connect://173.233.55.118:443'); 
	$browser->proxy(%proxy);
	$browser->timeout(30);
	$browser->agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36');
	
# 	my $req = new HTTP::Request('GET', $url);
# 	my $response = $browser->request($req);
	my $response = $browser->get($url);  				# 爬取的网址
	my $is_success = $response->is_success();			# 1
	my $content_type = $response->content_type();		# text/html
	my $content = $response->content();					# 网页正文
	my $content_length = length($content);				# 网页正文长度
	
	print "$is_success\n";
	print "$content_type\n";
	print "$content_length\n";
	print "$content\n";
}


test_http($mimvp_url, %proxy_http);			# http
test_https($mimvp_url2, %proxy_https);		# https (NO Success)
test_connect($mimvp_url2, %proxy_connect);	# https (connect)



## 执行命令
## perl -d mimvp-proxy-perl.pl
	  

PHP 示例

/**
 * PHP 支持 http、https、socks4、socks5、tcp
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2017.5.25
 * 
 * CURLOPT_PROXYTYPE :
 * 	CURLPROXY_HTTP,    CURLPROXY_HTTP_1_0
 * 	CURLPROXY_SOCKS4,  CURLPROXY_SOCKS4A
 * 	CURLPROXY_SOCKS5,  CURLPROXY_SOCKS5_HOSTNAME
 */


$proxy_http = "http://138.68.165.154:3128";
$proxy_https = "https://202.53.169.199:3128";
$proxy_socks4 = "socks4://94.158.70.129:1080";
$proxy_socks5 = "socks5://173.230.95.147:45454";

$proxy_tcp = "tcp://138.68.165.154:3128";

$mimvp_url = "http://proxy.mimvp.com/exist.php";
$mimvp_url2 = "https://proxy.mimvp.com/exist.php";
$mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js";


// curl
proxy_curl($proxy_http, $mimvp_url);			// http
proxy_curl($proxy_https, $mimvp_url);		// https
proxy_curl($proxy_socks4, $mimvp_url);		// socks4
proxy_curl($proxy_socks5, $mimvp_url);		// socks5

// stream
proxy_stream($proxy_tcp, $mimvp_url);			// tcp



// php curl 支持 http、https、socks4、socks5
function proxy_curl($proxy_uri, $mimvp_url) {
	$key = explode('://', $proxy_uri)[0];		// http
	$proxy= explode('://', $proxy_uri)[1];		// ip:port
	echo "proxy_uri :  $proxy_uri; key : $key, proxy : $proxy 
"; $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $mimvp_url); curl_setopt ( $ch, CURLOPT_HTTPPROXYTUNNEL, false ); curl_setopt ( $ch, CURLOPT_PROXY, $proxy ); if ($key == "http") { curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP ); // http } elseif ($key == "https") { curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 2 ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false ); // https } elseif ($key == "socks4") { curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 ); // socks4 } elseif ($key == "socks5") { curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5 ); // socks5 } else { curl_setopt ( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP ); } curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 ); curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 60 ); curl_setopt ( $ch, CURLOPT_HEADER, false ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); // 返回网页内容 $result = curl_exec ( $ch ); // 打印网页正文 print_r($result); // 打印网页大小 $curl_info = curl_getinfo($ch); echo $curl_info['size_download'] . "

"; curl_close ( $ch ); } // php stream 支持 tcp function proxy_stream($proxy_uri, $mimvp_url) { $key = explode('://', $proxy_uri)[0]; // http $proxy= explode('://', $proxy_uri)[1]; // ip:port echo "proxy_uri : $proxy_uri; key : $key, proxy : $proxy
"; $header_array = array( "Accept-Language:zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4", "Referer:http://proxy.mimvp.com/fetch.php", "Host:proxy.mimvp.com", "User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"); $options = array("http" => array( "proxy" => $proxy_uri, "header" => $header_array, "method" => "GET") ); $context = stream_context_create($options); $result = file_get_contents($mimvp_url, false, $context); print_r($result); }

Python2 示例

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Python2 支持 http、https、socks4、socks5
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2015-11-09


import urllib, urllib2
import socks, socket        # 需要引入socks.py文件,请到米扑代理下载
import ssl

import sys
reload(sys)
sys.setdefaultencoding('utf-8')


proxy_http = {"http":"http://138.68.165.154:3128"}
proxy_https = {"https":"http://191.252.103.93:8080"}
proxy_socks4 = {'socks4': '218.58.52.158:1088'} 
proxy_socks5 = {'socks5': '68.234.190.150:45454'}

mimvp_url = "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"


# 全局取消ssl证书验证,防止打开未验证的https网址抛出异常
# urllib2.URLError: [urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)]
ssl._create_default_https_context = ssl._create_unverified_context
            
            
# urllib2 支持 http, https
def test_http(proxy, mimvp_url):
    handler = urllib2.ProxyHandler(proxy)
    opener = urllib2.build_opener(handler)
    f = opener.open(mimvp_url, timeout=30)
    content = f.read()
    print content
    print len(content)
    f.close()
    opener.close()
    
    
# urllib 支持 http, https
def test_http2(proxy, mimvp_url):
    opener = urllib.FancyURLopener(proxy)
    f = opener.open(mimvp_url)                 #### mimvp_url 只能是http网页,不能是https网页
    content = f.read()
    print content
    print len(content)
    f.close()
    opener.close()
    
    
# socks4
def test_socks4(socks4, mimvp_url):
    socks4_ip = socks4.split(":")[0]
    socks4_port = int(socks4.split(":")[1])
    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, socks4_ip, socks4_port)
    socket.socket = socks.socksocket
    
    content = urllib2.urlopen(mimvp_url, timeout=30).read()
    print content
    print len(content)
    
    
# socks5
def test_socks5(socks5, mimvp_url):
    socks5_ip = socks5.split(":")[0]
    socks5_port = int(socks5.split(":")[1])
    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, socks5_ip, socks5_port)
    socket.socket = socks.socksocket
    
    content = urllib2.urlopen(mimvp_url, timeout=30).read()
    print content
    print len(content)
    


if __name__ == "__main__":
    # http, https
    test_http(proxy_http, mimvp_url)   
    test_http(proxy_https, mimvp_url2)    
    
    # http
    test_http2(proxy_http, mimvp_url)   
      
    # socks4
    test_socks4(proxy_socks4['socks4'], mimvp_url)
     
    # socks5
    test_socks5(proxy_socks5['socks5'], mimvp_url)
		

Python3 示例

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
#
# Python3 支持 http、https、socks4、socks5
# 
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2016-10-22


import urllib.request   # Python3将urllib和urllib2合二为一,并重组了下包结构
import socket
import socks            # 安装 pip3 install PySocks
import ssl


proxy_http = {"http":"http://183.222.102.98:80"}
proxy_https = {"https":"http://191.252.103.93:8080"}
proxy_socks4 = {'socks4': '186.121.206.241:1080'} 
proxy_socks5 = {'socks5': '68.180.33.124:45454'}

mimvp_url = "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"


# 全局取消ssl证书验证,防止打开未验证的https网址抛出异常
# urllib.error.URLError: 
ssl._create_default_https_context = ssl._create_unverified_context
            
            
# 不用代理,直接爬取网页
def test_url(mimvp_url):
    socket.setdefaulttimeout(30)
    req = urllib.request.Request(mimvp_url)
    content = urllib.request.urlopen(req).read()
    print(content)


# urllib 支持 http, https
def test_http(proxy, mimvp_url):
    socket.setdefaulttimeout(30)
    handler = urllib.request.ProxyHandler(proxy)  
    
#     auth_handler = urllib.request.ProxyBasicAuthHandler()  
#     opener = request.build_opener(handler, auth_handler, request.HTTPHandler)
    
    opener = urllib.request.build_opener(handler)  
    urllib.request.install_opener(opener)
    f = urllib.request.urlopen(mimvp_url)

    content = f.read()
    print(content)
    print(len(content))
    f.close()
    opener.close()


# socks4
def test_socks4(socks4, mimvp_url):
    socks4_ip = socks4.split(":")[0]
    socks4_port = int(socks4.split(":")[1])
    socks.set_default_proxy(socks.SOCKS4, socks4_ip, socks4_port)
    socket.socket = socks.socksocket
    
    content = urllib.request.urlopen(mimvp_url, timeout=30).read()
    print(content)
    print(len(content))
    
    
# socks5
def test_socks5(socks5, mimvp_url):
    socks5_ip = socks5.split(":")[0]
    socks5_port = int(socks5.split(":")[1])
    socks.set_default_proxy(socks.SOCKS5, socks5_ip, socks5_port)
    socket.socket = socks.socksocket
    
    content = urllib.request.urlopen(mimvp_url, timeout=30).read()
    print(content)
    print(len(content))
    


if __name__ == "__main__":
    test_url(mimvp_url)
    
    # http, https
    test_http(proxy_http, mimvp_url)   
    test_http(proxy_https, mimvp_url2)    

    # socks4
    test_socks4(proxy_socks4['socks4'], mimvp_url2)
      
    # socks5
    test_socks5(proxy_socks5['socks5'], mimvp_url2)
		

Python pyspider 示例

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: mimvp_proxy_pyspider
#
# Python pyspider 支持 http、https
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2017-07-22
#
# 米扑博客示例详解 : 
# http://blog.mimvp.com/2017/08/python-pyspider-an-zhuang-yu-kai-fa/


############  方式1:pyspider crawl_config  ############

from pyspider.libs.base_handler import *

class Handler(BaseHandler):
    crawl_config = {
        'proxy' : 'http://188.226.141.217:8080',     # http
        'proxy' : 'https://182.253.32.65:3128'       # https
    }

    @every(minutes=24 * 60)
    def on_start(self):
        self.crawl('http://proxy.mimvp.com/exist.php', callback=self.index_page)

    @config(age=10 * 24 * 60 * 60)
    def index_page(self, response):
        for each in response.doc('a[href^="http"]').items():
            self.crawl(each.attr.href, callback=self.detail_page)

    @config(priority=2)
    def detail_page(self, response):
        return {
            "url": response.url,
            "title": response.doc('title').text(),
        }
        
        
        
############  方式2:pyspider --phantomjs-proxy 启动  ############

# $ pyspider --help
# Usage: pyspider [OPTIONS] COMMAND [ARGS]...
# 
#   A powerful spider system in python.
# 
# Options:
#   -c, --config FILENAME           a json file with default values for
#                                   subcommands. {"webui": {"port":5001}}
#   --logging-config TEXT           logging config file for built-in python
#                                   logging module  [default: /Library/Framework
#                                   s/Python.framework/Versions/2.7/lib/python2.
#                                   7/site-packages/pyspider/logging.conf]
#   --debug                         debug mode
#   --queue-maxsize INTEGER         maxsize of queue
#   --taskdb TEXT                   database url for taskdb, default: sqlite
#   --projectdb TEXT                database url for projectdb, default: sqlite
#   --resultdb TEXT                 database url for resultdb, default: sqlite
#   --message-queue TEXT            connection url to message queue, default:
#                                   builtin multiprocessing.Queue
#   --amqp-url TEXT                 [deprecated] amqp url for rabbitmq. please
#                                   use --message-queue instead.
#   --beanstalk TEXT                [deprecated] beanstalk config for beanstalk
#                                   queue. please use --message-queue instead.
#   --phantomjs-proxy TEXT          phantomjs proxy ip:port
#   --data-path TEXT                data dir path
#   --add-sys-path / --not-add-sys-path
#                                   add current working directory to python lib
#                                   search path
#   --version                       Show the version and exit.
#   --help                          Show this message and exit.
   
pyspider --phantomjs-proxy "188.226.141.217:8080" all
		

Python requests 示例

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# Python requests 支持 http、https、socks4、socks5
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2016-09-16


import requests
import ssl
import socks, socket    # 需要引入socks.py文件,请到米扑代理下载


mimvp_url = "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"
            
            
# 使用代理 http, https
proxies = { 
            "http"  : "http://120.77.155.249:8888", 
            "https" : "http://54.255.211.38:80", 
           }   
  
req = requests.get(mimvp_url2, proxies=proxies, timeout=30, verify=False) 
print("mimvp text : " + req.text)



# 使用代理 socks4
proxies = { 
            'socks4' : '163.121.188.2:4000',
           }   
 
socks4_ip = proxies['socks4'].split(":")[0]
socks4_port = int(proxies['socks4'].split(":")[1])
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, socks4_ip, socks4_port)
socket.socket = socks.socksocket
 
req = requests.get(mimvp_url2, timeout=30, verify=False) 
print("mimvp text : " + req.text)



# 使用代理 socks5
proxies = { 
            'socks5' : '190.9.58.211:45454',
           }   
  
socks5_ip = proxies['socks5'].split(":")[0]
socks5_port = int(proxies['socks5'].split(":")[1])
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, socks5_ip, socks5_port)
socket.socket = socks.socksocket
  
req = requests.get(mimvp_url2, timeout=30, verify=False) 
print("mimvp text : " + req.text)
 
 
 
 
 
 
################### requests 简单示例 ###################
 
# 爬取米扑科技首页
req = requests.get(url = 'http://mimvp.com')
print("status_code : " + str(req.status_code))
print("mimvp text : " + req.text)
  
  
# 爬取米扑代理(含请求参数)
req = requests.get(url='http://proxy.mimvp.com/free.php', params={'proxy':'out_tp','sort':'p_ping'})   
print("status_code : " + str(req.status_code))
print("mimvp text : " + req.text)
		

Python scrapy 示例

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Python scrapy 支持 http、https
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2016.10.1

# Python Scrapy 设置代理有两种方式,使用时两种方式选择一种即可
# 方式1: 直接在代码里设置,如 MimvpSpider ——> start_requests
# 方式2: 通过 middlewares.py + settings.py 配置文件设置,步骤:
#        2.1 middlewares.py 添加代理类 ProxyMiddleware,并添加代理
#        2.2 settings.py 开启 DOWNLOADER_MIDDLEWARES,并且添加 'mimvp_proxy_python_scrapy.middlewares.ProxyMiddleware': 100
#
# 米扑博客想写介绍了 Python scrapy 设置代理的两种方式(附源码)
# http://blog.mimvp.com/2017/08/python-scrapy-she-zhi-dai-li-de-liang-zhong-fang-shi-fu-yuan-ma/


import scrapy
 
 
################################ 方式1:直接代码设置代理 ################################
        
        
class MimvpSpider(scrapy.spiders.Spider):
    name = "mimvp"
    allowed_domains = ["mimvp.com"]
    start_urls = [
        "http://proxy.mimvp.com/exist.php",
        "https://proxy.mimvp.com/exist.php",
    ]
 
    ## 代理设置方式1:直接在代理里设置
    def start_requests(self):
        urls = [
            "http://proxy.mimvp.com/exist.php",
            "https://proxy.mimvp.com/exist.php",
        ]
        for url in urls:
            meta_proxy = ""
            if url.startswith("http://"):
                meta_proxy = "http://180.96.27.12:88"           # http代理
            elif url.startswith("https://"):
                meta_proxy = "http://109.108.87.136:53281"      # https代理
                
            yield scrapy.Request(url=url, callback=self.parse, meta={'proxy': meta_proxy})


    def parse(self, response):
        mimvp_url = response.url                    # 爬取时请求的url
        body = response.body                        # 返回网页内容
        
        print("mimvp_url : " + str(mimvp_url))
        print("body : " + str(body))
        
        
        
        
################################ 方式2:配置文件设置代理 ################################
        
        
# 配置文件设置代理,需要同时在 middlewares.py + settings.py 两个文件里配置,详细步骤:

## a) middlewares.py 文件里,添加代码:
## 代理设置方式2: 通过 middlewares.py + settings.py 配置文件设置
## mimvp custom by yourself
class ProxyMiddleware(object):
    def process_request(self,request,spider):
      
        if request.url.startswith("http://"):
            request.meta['proxy']="http://180.96.27.12:88"          # http代理
        elif request.url.startswith("https://"):
            request.meta['proxy']="http://109.108.87.136:53281"         # https代理
                  
#         # proxy authentication
#         proxy_user_pass = "USERNAME:PASSWORD"
#         encoded_user_pass = base64.encodestring(proxy_user_pass)
#         request.headers['Proxy-Authorization'] = 'Basic ' + encoded_user_pass


## b)settings.py 文件里,开启设置 DOWNLOADER_MIDDLEWARES
DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,  
    'mimvp_proxy_python_scrapy.middlewares.ProxyMiddleware': 100,  


## c) 代码里编写爬虫
## vim  mimvp_spider.py
import scrapy
  
class MimvpSpider(scrapy.spiders.Spider):
    name = "mimvp"
    allowed_domains = ["mimvp.com"]
    start_urls = [
        "http://proxy.mimvp.com/exist.php",
        "https://proxy.mimvp.com/exist.php",
    ]
 
 
    def parse(self, response):
        mimvp_url = response.url                    # 爬取时请求的url
        body = response.body                        # 返回网页内容
         
        print("mimvp_url : " + str(mimvp_url))
        print("body : " + str(body))
        
        
## 运行命令:
## scrapy crawl mimvp --nolog
		

Ruby 示例

#!/usr/bin/env ruby
#
# Ruby 支持 http
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2017-03-21


require 'rubygems' 
require 'net/http' 
require 'open-uri' 
require 'timeout' 


mimvp_url = "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"

$proxy = '183.222.102.95:8080'

$proxy_addr = $proxy.split(':')[0].strip
$proxy_port = $proxy.split(':')[1].strip

puts $proxy_addr
puts $proxy_port


begin 
  Timeout.timeout(30) {
    
    # mimvp_url = http://proxy.mimvp.com/exist.php
    # uri.host = proxy.mimvp.com
    # uri.port = 80
    # uri.path = /exist.php
    uri = URI.parse(mimvp_url)
    result = Net::HTTP.new(uri.host, nil, $proxy_addr, $proxy_port).start { |http|
      http.get(uri.path)
    }
    puts result.body
  

    # mimvp_url = http://proxy.mimvp.com/exist.php
    # uri.host = proxy.mimvp.com
    # uri.port = 80
    # uri.path = /exist.php
    # req = #
    uri = URI.parse(mimvp_url)
    req = Net::HTTP::Get.new(uri.path)
    result = Net::HTTP::Proxy($proxy_addr, $proxy_port).start(uri.host, uri.port) {|http| 
      http.request(req)
    } 
    puts result.body
    
    
#    # proxy auth (NO TEST)
#    $proxy_addr = 'proxy addr'
#    $proxy_port = 'proxy_port'
#    $proxy_user = 'username'                # 代理用户名
#    $proxy_pass = 'password'                # 代理密码
#    
#    $website_username = 'website_username'  # 目标网站登录用户名
#    $website_password = 'website_password'  # 目标网站登录密码
#    
#    uri = URI.parse(mimvp_url)
#    req = Net::HTTP::Get.new(uri.path)
#    req.basic_auth($website_username, $website_password)
#    
#    result = Net::HTTP::Proxy($proxy_addr, $proxy_port, $proxy_user, $proxy_pass).start(uri.host, uri.port) {|http| 
#      http.request(req)
#    } 
#    puts result.body
    
}
rescue => e  
    puts e.inspect  
    exit  
end 


## 运行命令: ruby mimvp-proxy-ruby.rb
		

Selenium Java 示例(FirefoxDriver + HtmlUnitDriver)

/**
 * Selenum FirefoxDriver 支持 http、socks5
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2015-11-09
 */


package com.mimvp;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class MimvpProxy_FirefoxDriver {

	final static String proxyUri = "103.35.171.77:8080";				// 代理服务器(HTTP, HTTPS)
	final static String proxySocks = "50.63.167.102:18628";				// 代理服务器(Socks5)
	final static String mimvpUrl = "http://proxy.mimvp.com/exist.php";	// 爬取网址
	
//	final static String firefoxBin = "D:/Program Files/Mozilla Firefox/firefox.exe";			// Windows
//	final static String firefoxBin = "/usr/bin/firefox-bin";									// Linux
	final static String firefoxBin = "/Applications/Firefox.app/Contents/MacOS/firefox-bin";	// Mac

	public static void main(String[] args) {
		getNoProxy();
		getHttpProxy();
		getSocksProxy();
	}

	// 不用代理爬取网页
	public static void getNoProxy() {
//		System.setProperty("webdriver.firefox.bin", firefoxBin);	// 不设置也可以
		
		FirefoxProfile profile = new FirefoxProfile();
        
        // 启动Firefox,抓取网页后,再关闭Firefox
        FirefoxDriver driver = new FirefoxDriver(profile);
        driver.get(mimvpUrl);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
		driver.quit();
		driver.close();
	}

	// HTTP和HTTPS代理爬取网页
	public static void getHttpProxy() {
		FirefoxProfile profile = new FirefoxProfile();
		
		// 设置代理
		profile.setPreference("network.proxy.type", 1);		// 0 - 不用代理; 1 - 使用代理
		profile.setPreference("network.proxy.http", proxyUri.split(":")[0]);
        profile.setPreference("network.proxy.http_port", Integer.parseInt(proxyUri.split(":")[1]));
        profile.setPreference("network.proxy.ssl", proxyUri.split(":")[0]);
        profile.setPreference("network.proxy.ssl_port", Integer.parseInt(proxyUri.split(":")[1]));
        profile.setPreference("network.proxy.no_proxies_on", "localhost");
        
//        // 代理设置用户名和密码,无密码的代理无需配置
//        profile.setPreference("username", "mimvp-user");
//        profile.setPreference("password", "mimvp-pwd");

        FirefoxDriver driver = new FirefoxDriver(profile);
        driver.get(mimvpUrl);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
		driver.close();
	}

	// Socks5代理爬取网页
	public static void getSocksProxy() {
		FirefoxProfile profile = new FirefoxProfile();
		
		// 设置代理
		profile.setPreference("network.proxy.type", 1);		// 0 - 不用代理; 1 - 使用代理
		profile.setPreference("network.proxy.socks", proxySocks.split(":")[0]);
	    profile.setPreference("network.proxy.socks_port", Integer.parseInt(proxySocks.split(":")[1]));
        profile.setPreference("network.proxy.no_proxies_on", "localhost");

        FirefoxDriver driver = new FirefoxDriver(profile);
        driver.get(mimvpUrl);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
		driver.close();
	}
}
		
-----------------------------------------
		
/**
 * Selenum HtmlUnitDriver 支持 http、socks5
 * 
 * 米扑代理示例:
 * http://proxy.mimvp.com/demo2.php
 * 
 * 米扑代理购买:
 * http://proxy.mimvp.com
 * 
 * mimvp.com
 * 2015-11-09
 */


package com.mimvp;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Platform;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.gargoylesoftware.htmlunit.DefaultCredentialsProvider;
import com.gargoylesoftware.htmlunit.WebClient;

public class MimvpProxy_HtmlUnitDriver {
	final static String proxyUri = "183.222.102.98:8080";				// 代理服务器(HTTP)
	final static String proxySocks = "103.14.27.174:1080";				// 代理服务器(Socks5)
	final static String mimvpUrl = "http://proxy.mimvp.com/exist.php";	// 爬取网址

	public static void main(String[] args) {
		getNoProxy();
		getHttpProxy();
		getSocksProxy();
		getAuthProxy();
		getBaiduSearch("米扑科技");
	}

	// 不用代理爬取网页
	public static void getNoProxy() {
		HtmlUnitDriver driver = new HtmlUnitDriver(true);	// enable javascript
		driver.setJavascriptEnabled(true);
		driver.get(mimvpUrl);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
	}
	
	
	// HTTP代理爬取网页
	public static void getHttpProxy() {
		HtmlUnitDriver driver = new HtmlUnitDriver(true);	// enable javascript
		
		// 方法1
		driver.setProxy(proxyUri.split(":")[0], Integer.parseInt(proxyUri.split(":")[1]));		// proxyUri = "183.222.102.98:8080"
		
		// 方式2
		driver.setHTTPProxy(proxyUri.split(":")[0], Integer.parseInt(proxyUri.split(":")[1]), null);	// proxyUri = "183.222.102.98:8080"

		// 方法3
		Proxy proxy = new Proxy();
		proxy.setHttpProxy(proxyUri);		// 设置代理服务器地址, proxyUri = "183.222.102.98:8080"
		driver.setProxySettings(proxy);
		
		driver.get(mimvpUrl);
		
		String html = driver.getPageSource();
		System.out.println(html);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
	}

	
	// Socks5代理爬取网页
	public static void getSocksProxy() {
		HtmlUnitDriver driver = new HtmlUnitDriver(true);	// enable javascript
		
		// 方式1
		driver.setSocksProxy(proxySocks.split(":")[0], Integer.parseInt(proxySocks.split(":")[1]));			// proxySocks = "183.239.240.138:1080"
		
		// 方式2
		driver.setSocksProxy(proxySocks.split(":")[0], Integer.parseInt(proxySocks.split(":")[1]), null);	// proxySocks = "183.239.240.138:1080"
		
		driver.get(mimvpUrl);
		
		String html = driver.getPageSource();
		System.out.println(html);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
	}

	
	// 代理需要用户名和密码
	public static void getAuthProxy() {
		HtmlUnitDriver driver = null;
		
		final String proxyUser = "mimvp-user";
        final String proxyPass = "mimvp-pwd";
        
		Proxy proxy = new Proxy();
		proxy.setHttpProxy(proxyUri);	

		// 设置代理的用户名和密码
		DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
		capabilities.setCapability(CapabilityType.PROXY, proxy);
		capabilities.setJavascriptEnabled(true);
		capabilities.setPlatform(Platform.WIN8_1);
		driver = new HtmlUnitDriver(capabilities) {
			@Override
			protected WebClient modifyWebClient(WebClient client) {
				DefaultCredentialsProvider creds = new DefaultCredentialsProvider();
				creds.addCredentials(proxyUser, proxyPass);
				client.setCredentialsProvider(creds);
				return client;
			}
		};
		driver.setJavascriptEnabled(true);	// enable javascript
		driver.get(mimvpUrl);
		String title = driver.getTitle();
		System.out.println(title);			// 检测收录 - 米扑代理
	}

	
	// 进行百度搜索
	public static void getBaiduSearch(String keyword) {
		final String url = "http://www.baidu.com";
		WebDriver driver = new HtmlUnitDriver(false);
		driver.get(url);
		driver.findElement(By.id("kw")).sendKeys(keyword);
		Actions action = new Actions(driver);
		action.sendKeys(Keys.ENTER).perform();
		String html = driver.getPageSource();
		System.out.println(html);
	}
}
		
		

Selenium Python 示例(PhantomJS)

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Selenium PhantomJS 支持 http、socks5
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
# 
# 米扑代理购买:
# http://proxy.mimvp.com
# 
# mimvp.com
# 2017-01-08


from selenium import webdriver


proxy_http = "http://138.68.165.154:3128"
proxy_socks5 = "socks5://209.151.135.126:11747"

mimvp_url = "http://proxy.mimvp.com/exist.php"
mimvp_url2 = "https://proxy.mimvp.com/exist.php"
mimvp_url3 = "https://apps.bdimg.com/libs/jquery-i18n/1.1.1/jquery.i18n.min.js"



# urllib2 支持 http, https
def test_http(proxy, mimvp_url):
    
    proxy_type = proxy.split("://")[0]
    proxy_ip = proxy.split("://")[1].split(":")[0]
    proxy_port = int(proxy.split("://")[1].split(":")[1])
    
    # 使用PhantomJS命令,因PhantomJS仅支持http、socks5,所以Selenium Webdriver也只支持http、socks5
    service_args = [
            "--proxy-type=%(http)s" % {"http" : proxy_type},
            "--proxy=%(host)s:%(port)s" % {
                "host" : proxy_ip,
                "port" : proxy_port,
            },
    #         "--proxy-auth=%(user)s:%(pass)s" % {
    #             "user" : 'mimvp-user',
    #             "pass" : 'mimvp-pass',
    #         },
        ]
    
    phantomjs_path = r"/opt/phantomjs-2.1.1/bin/phantomjs"
    
    driver = webdriver.PhantomJS(executable_path=phantomjs_path, service_args=service_args)
    driver.get(mimvp_url)
    
    print driver.title
    print driver.page_source.encode("utf-8")
    
    driver.quit()      



if __name__ == "__main__":
    # http, socks5
    test_http(proxy_http, mimvp_url)   
    test_http(proxy_socks5, mimvp_url)   
		

Shell curl wget 示例

#!/bin/bash
#
# curl 支持 http、https、socks4、socks5
# wget 支持 http、https
#
# 米扑代理示例:
# http://proxy.mimvp.com/demo2.php
#
# 米扑代理购买:
# http://proxy.mimvp.com
#
# mimvp.com
# 2015-11-09


# http代理格式 		http_proxy=http://IP:Port
# https代理格式 		https_proxy=http://IP:Port

{'http': 'http://120.77.176.179:8888'}
curl -m 30 --retry 3 -x http://120.77.176.179:8888 http://proxy.mimvp.com/exist.php        				# http_proxy
wget -T 30 --tries 3 -e "http_proxy=http://120.77.176.179:8888" http://proxy.mimvp.com/exist.php  		# http_proxy

{'https': 'http://46.105.214.133:3128'}
curl -m 30 --retry 3 -x http://46.105.214.133:3128 -k https://proxy.mimvp.com/exist.php        								# https_proxy
wget -T 30 --tries 3 --no-check-certificate -e "https_proxy=http://46.105.214.133:3128" https://proxy.mimvp.com/exist.php	# https_proxy

    
# curl  支持socks
{'socks4': '101.255.17.145:1080'}
curl -m 30 --retry 3 --socks4 101.255.17.145:1080 http://proxy.mimvp.com/exist.php
    
{'socks5': '82.164.233.227:45454'}
curl -m 30 --retry 3 --socks5 82.164.233.227:45454 http://proxy.mimvp.com/exist.php


# wget 不支持socks




################### wget配置文件设置代理 ###################

vim ~/.wgetrc

http_proxy=http://120.77.176.179:8888:8080
https_proxy=http://12.7.17.17:8888:8080
use_proxy = on
wait = 30

wget -T 30 --tries 3 http://proxy.mimvp.com




################### 设置临时局部代理 ###################

# proxy no auth
export http_proxy=http://120.77.176.179:8888:8080
export https_proxy=http://12.7.17.17:8888:8080

# proxy auth
export http_proxy=http://username:password@120.77.176.179:8888:8080
export https_proxy=http://username:password@12.7.17.17:8888:8080


# 取消设置
unset http_proxy
unset https_proxy




################### 设置系统全局代理 ###################

# 修改 /etc/profile,保存并重启服务器
sudo vim /etc/profile		# 所有人有效
或
sudo vim ~/.bashrc			# 所有人有效
或
vim ~/.bash_profile			# 个人有效
	
	
# proxy no auth
export http_proxy=http://120.77.176.179:8888:8080
export https_proxy=http://12.7.17.17:8888:8080

# proxy auth
export http_proxy=http://username:password@120.77.176.179:8888:8080
export https_proxy=http://username:password@12.7.17.17:8888:8080

source /etc/profile
或
source ~/.bashrc
或
source ~/.bash_profile


sudo reboot
		

易语言 示例

' 易语言 支持 http
' 
' 米扑代理示例:
' http://proxy.mimvp.com/demo2.php
' 
' 米扑代理购买:
' http://proxy.mimvp.com
' 
' mimvp.com
' 2017-07-28
' 
' 易语言的安装与开发,请参考米扑博客:
' http://blog.mimvp.com/2017/08/yi-yu-yan-de-an-zhuang-yu-kai-fa/
' 
' 易语言的网络编程和代理示例,请参考米扑博客,附有源代码:
' http://blog.mimvp.com/2017/08/yi-yu-yan-de-wang-luo-bian-cheng-he-dai-li-shi-li/


' 变量声明(表格)
.局部变量 代理地址, 文本型
.局部变量 目标网址, 文本型
.局部变量 代理用户名, 文本型
.局部变量 代理密码, 文本型
 
 

' 获取目标网址
.如果 (目标网址编辑框.内容 = “”)
    目标网址 = “http://proxy.mimvp.com/exist.php”
.否则
    目标网址 = 目标网址编辑框.内容
    
' 获取代理地址
.如果 (代理服务器编辑框.内容 = “”)
    代理地址 = “139.59.99.113:8080”
.否则
    代理地址 = 代理服务器编辑框.内容
 
.如果结束
 
输出调试文本 (“代理地址: ” + 代理地址)
 
' 设置代理方法1
网页_置浏览器代理 (代理地址)  ' 通过浏览器设置,一般只支持http代理
超文本浏览框.跳转 (目标网址编辑框.内容, , )
 
 
' 设置代理方法2
输出调试文本 (网页_访问S (目标网址, , , , , , , , , , 代理地址, , ))
 
 
' 设置代理方式3(用户名 + 密码)
输出调试文本 (网页_访问S (目标网址, , , , , , , , , , 代理地址, 代理用户名, 代理密码))
		


# 易语言源码:



# 易语言代理设置: