> ## Documentation Index
> Fetch the complete documentation index at: https://docs.antsdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python

> Learn how to use python to make requests with proxies.

<Accordion title="requests" defaultOpen>
  ```Python requests theme={null}
  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)
  ```
</Accordion>

<Accordion title="aiohttp">
  ```Python aiohttp theme={null}
  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())
  ```
</Accordion>

<Accordion title="Selenium">
  Running Selenium Webdriver with a proxy in Python, we recommend using **selenium-wire** because it supports proxies with credentials.

  ```Python Selenium theme={null}
  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)
  ```
</Accordion>
