Proxies
- Residential Proxies
- ISP Proxies
- Datacenter Proxies
- Mobile Proxies
- Authentication Methods
Integrations
- Operating System
- Browser
- Code
- 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.antsdata.com:40000"
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.antsdata.com:40000"
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.antsdata.com:40000"
seleniumwire_options = {
'proxy': {
'http': proxy,
'https': proxy
}
}
chrome_options = ChromeOptions()
driver = webdriver.Chrome(options = chrome_options, seleniumwire_options=seleniumwire_options)
driver.get(target_url)