Goproxy home pagelight logodark logo
  • Help Center
  • Dashboard
  • Dashboard
Code
Python
Documentation
API References
Troubleshooting
  • GoProxy Documentation
Proxies
  • Residential Proxies
  • Static Residential Proxies
  • Datacenter Proxies
  • Mobile Proxies
  • Authentication Methods
Integrations
  • Operating System
  • Browser
  • Code
    • Python
    • JavaScript
  • Proxy Managers
Code

Python

Learn how to use python to make requests with proxies.

requests
import requests

target_url = "https://httpbin.org/ip"
username = "your_proxy_username"
password = "your_proxy_password"
proxy = f"http://{username}:{password}@proxy.goproxy.com:30000"
proxies = {
    "http": proxy,
    "https": proxy
}

response = requests.get(target_url, proxies = proxies)
print(response.text)
aiohttp
import asyncio
import aiohttp

target_url = "https://httpbin.org/ip"
username = "your_proxy_username"
password = "your_proxy_password"
proxy = f"http://{username}:{password}@proxy.goproxy.com:30000"

async def request(target_url):
    async with aiohttp.ClientSession() as session:
        response = await session.get(target_url, proxy=proxy)
    return response

async def main():
    response = await request(target_url)
    response_text = await response.text()
    print(response_text)

asyncio.run(main())

Running Selenium Webdriver with a proxy in Python, we recommend using selenium-wire because it supports proxies with credentials.

Selenium
from seleniumwire import webdriver
from selenium.webdriver import ChromeOptions

target_url = "https://httpbin.org/ip"
username = "your_proxy_username"
password = "your_proxy_password"
proxy = f"http://{username}:{password}@proxy.goproxy.com:30000"
seleniumwire_options = {
        'proxy': {
            'http': proxy, 
            'https': proxy
        }
}

chrome_options = ChromeOptions()
driver = webdriver.Chrome(options = chrome_options, seleniumwire_options=seleniumwire_options)
driver.get(target_url)
Browser ExtensionsJavaScript
Powered by Mintlify