Python

Examples of python requests with our residential packages are shown using the popular Requests and urllib3 libraries.

Python Requests



In this example, we use the Residential proxy below:


resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass


This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon and then add it, with authentication, to our proxy dictionary.


proxy_string= "resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass"  
  
proxy_parts = proxy_string.split(":")  
ip_address = proxy_parts[0]  
port = proxy_parts[1]  
username = proxy_parts[2]  
password = proxy_parts[3]  
  
proxies = {  
    "http" :"http://{}:{}@{}:{}".format(username,password,ip_address,port),  
    "https":"http://{}:{}@{}:{}".format(username,password,ip_address,port),  
}


HTTP


r = requests.get("http://www.google.com/", proxies=proxies)
r.status_code # 200 OK

Python urllib3



In this example, we use the Residential proxy below:


resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass


This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon and then using the ProxyManager function in urllib3 we add and authenticate the proxy.


from urllib3 import ProxyManager, make_headers  
  
proxy_string= "resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass"  
  
proxy_parts = proxy_string.split(":")  
ip_address = proxy_parts[0]  
port = proxy_parts[1]  
username = proxy_parts[2]  
password = proxy_parts[3]  
  
default_headers = make_headers(proxy_basic_auth='{}:{}'.format(username,password))  
http = ProxyManager("http://{}:{}/".format(ip_address,port), proxy_headers=default_headers)


Now you can use http as you would a normal PoolManager


r = http.request('GET', 'https://www.google.com/')

Updated on: 20/02/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!