Introduction


Hello! This article will explain how you can implement your rotating residential proxy into your Python code. If you have any questions that this article does not help answer, please feel free to reach out to our team at support@rayobyte.com.



Prerequisites


Latest version of Python Requests library:


 https://docs.python-requests.org/en/latest/




Example Code


import requests

url = "https://www.rayobyte.com/"
proxies = {
    "https": f"http://PROXY_LOGIN:PROXY_PASS@PROXY_IP:PROXY_PORT/"
}
headers = {
    'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36',
    'content-encoding': 'gzip'
}


r = requests.get(url, headers=headers, proxies=proxies)

print(f"Response Body: {r.text}\n"
    "Request Headers:"
    f"{r.request.headers}\n\n"
    f"Response Time: {r.elapsed.total_seconds()}\n"
    f"Response Code: {r.status_code}\n"
    f"Response Headers: {r.headers}\n\n"
    f"Response Cookies: {r.cookies.items()}\n\n"
    f"Requesting {url}\n"
)