Overview Introduction
This guide provides code examples for integrating Fusion Proxy with various programming languages, frameworks, and tools. Each example shows how to configure proxy authentication and make requests.
Step 1 Python with Requests
The most popular Python HTTP library. Install with pip install requests.
import requests
proxies = {
"http": "http://username:[email protected]:12286",
"https": "http://username:[email protected]:12286"
}
# Basic request
response = requests.get("https://httpbin.org/ip", proxies=proxies)
print(response.json())
# With geo-targeting (USA)
proxies_us = {
"http": "http://username-country-us:[email protected]:12286",
"https": "http://username-country-us:[email protected]:12286"
}
response = requests.get("https://httpbin.org/ip", proxies=proxies_us)Step 2 Node.js with Axios
Popular HTTP client for Node.js. Install with npm install axios https-proxy-agent.
const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent');
const proxyUrl = 'http://username:[email protected]:12286';
const agent = new HttpsProxyAgent(proxyUrl);
async function makeRequest() {
const response = await axios.get('https://httpbin.org/ip', {
httpsAgent: agent,
proxy: false // Important: disable axios default proxy
});
console.log(response.data);
}
makeRequest();Step 3 cURL Command Line
Test proxies directly from your terminal.
# Basic request
curl -x "http://username:[email protected]:12286" \
"https://httpbin.org/ip"
# With geo-targeting
curl -x "http://username-country-de:[email protected]:12286" \
"https://httpbin.org/ip"
# SOCKS5 protocol
curl -x "socks5://username:[email protected]:5390" \
"https://httpbin.org/ip"Step 4 PHP with cURL
Native PHP cURL support for proxy connections.
<?php
$proxy = 'http://username:[email protected]:12286';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/ip');
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>Step 5 Go (Golang)
Using the standard net/http package with proxy support.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
func main() {
proxyURL, _ := url.Parse("http://username:[email protected]:12286")
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
},
}
resp, err := client.Get("https://httpbin.org/ip")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}Step 6 Puppeteer (Headless Browser)
For browser automation with JavaScript. Install with npm install puppeteer.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
args: [
'--proxy-server=http://resi.fusionproxy.net:12286'
]
});
const page = await browser.newPage();
// Set proxy authentication
await page.authenticate({
username: 'your_username',
password: 'your_password'
});
await page.goto('https://httpbin.org/ip');
const content = await page.content();
console.log(content);
await browser.close();
})();Step 7 Selenium (Python)
Browser automation with Python. Install with pip install selenium.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
# Configure proxy
PROXY = "resi.fusionproxy.net:12286"
USERNAME = "your_username"
PASSWORD = "your_password"
# Chrome options with proxy
chrome_options = Options()
chrome_options.add_argument(f'--proxy-server=http://{PROXY}')
# Note: For authenticated proxies, use a proxy extension
# or selenium-wire package for easier handling
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://httpbin.org/ip")
print(driver.page_source)
driver.quit()Step 8 Scrapy Middleware
For large-scale web scraping with Python Scrapy.
# In settings.py
DOWNLOADER_MIDDLEWARES = {
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}
# In your spider or middleware
class ProxyMiddleware:
def process_request(self, request, spider):
request.meta['proxy'] = 'http://username:[email protected]:12286'
return None
# Or set globally in settings.py
HTTP_PROXY = 'http://username:[email protected]:12286'Summary Conclusion
These examples cover the most common integration scenarios. For language-specific questions or advanced configurations, check our API documentation or contact support.