var request = require('request');
request({
'url':'http://ipinfo.io',
'method': "GET",
'proxy':'http://USERNAME:PASSWORD@Proxy Server:PORT'
},function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
})
import requests
proxies = {
'http': 'http://USERNAME:PASSWORD@Proxy Server:PORT',
'https': 'http://USERNAME:PASSWORD@Proxy Server:PORT',
}
r = requests.get('http://ipinfo.io', proxies=proxies)
print(r.text)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ipinfo.io");
curl_setopt($ch, CURLOPT_PROXY, "Proxy Server:PORT");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USERNAME:PASSWORD");
$result = curl_exec($ch);
curl_close($ch);
echo $result;
import java.net.*;
import java.io.*;
public class ProxyTest {
public static void main(String[] args) throws Exception {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("Proxy Server", PORT));
URL url = new URL("http://ipinfo.io");
HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);
String encoded = new String(java.util.Base64.getEncoder().encode("USERNAME:PASSWORD".getBytes()));
uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
uc.connect();
}
}
package main
import (
"fmt"
"net/http"
"net/url"
"io/ioutil"
)
func main() {
proxyUrl, _ := url.Parse("http://USERNAME:PASSWORD@Proxy Server:PORT")
client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
resp, _ := client.Get("http://ipinfo.io")
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
// C++ Example using libcurl
#include
#include
int main(void) {
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://ipinfo.io");
curl_easy_setopt(curl, CURLOPT_PROXY, "http://Proxy Server:PORT");
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "USERNAME:PASSWORD");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}