Login to access the members area from where you can purchase new proxies or VPNs,
or administrate your current subscriptions. If you don't have an account Create one!

How to use the proxies in various programming languages

How to use the proxies in various programming languages

This article is a small colletion of snippets with examples on how to test the proxies using some of the most popular programming languages.

PHP

In PHP we use the cURL library to test the proxies. cURL is widely used and stable and we have great results with it

function testProxy ( $user, $pass, $ip, $port, $url ) {
    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXY, "$ip:$port");
    curl_setopt($ch, CURLOPT_PROXYPORT, $port);
    curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "$user:$pass");

    $x = curl_exec($ch);

    print $x . curl_error($ch) ;

    curl_close($ch);
}

Python

In Python we use the urllib2 library. We could also use the pycurl module but we will keep it simple for now.

import urllib2

uri = "http://anonymous-proxies.net/index.php?r=tools/showip"
http_proxy_server = "xxx.xxx.xx.x"
http_proxy_port = "10000"
http_proxy_realm = http_proxy_server
http_proxy_user = "proxy_username"
http_proxy_passwd = "proxy_password"

http_proxy_full_auth_string = "http://%s:%s@%s:%s" % (
	http_proxy_user,
	http_proxy_passwd,
	http_proxy_server,
	http_proxy_port
)

def open_url_installed_opener():
	proxy_handler = urllib2.ProxyHandler({"http": http_proxy_full_auth_string})
	
	opener = urllib2.build_opener(proxy_handler)
	urllib2.install_opener(opener)
	response = urllib2.urlopen(uri)
	
	print response.read()

if __name__ == "__main__":
	open_url_installed_opener()

If you have other snippets of code you want to share with us and contribute to this resource please don't hesitate to contact us with your code.

Important links

Recently published articles

Twitter updates

Follow us on twitter! and be up to date with our changes, new server additions or problems, service statuses and more.