Skip to main content
ubuntuask.com

Back to all posts

How to Use A Proxy In Selenium Python?

Published on
4 min read
How to Use A Proxy In Selenium Python? image

Best Proxy Tools for Selenium Python to Buy in September 2026

1 Handmade Attachment Accessories Replacement for Proxy Parts,Champagne, Sagittarius (Black-White)

Handmade Attachment Accessories Replacement for Proxy Parts,Champagne, Sagittarius (Black-White)

  • UNIQUE HANDMADE DESIGN: STAND OUT WITH EXCLUSIVE BLACK-WHITE STYLE.
  • DURABLE GLASS: PREMIUM QUALITY FOR LONG-LASTING ACCESSORY PERFORMANCE.
  • PERFECT FIT: TAILORED REPLACEMENTS FOR PROXY PARTS AND CHAMPAGNE GLASS.
BUY & SAVE
$32.99
Handmade Attachment Accessories Replacement for Proxy Parts,Champagne, Sagittarius (Black-White)
2 Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (A)

Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (A)

  • DURABLE DESIGN ENHANCES TIP LONGEVITY AND REDUCES REPLACEMENT COSTS.
  • PRECISION FIT ENSURES SEAMLESS WELDING PERFORMANCE AND IMPROVED RESULTS.
  • EASY INSTALLATION MINIMIZES DOWNTIME FOR INCREASED PRODUCTIVITY ON-SITE.
BUY & SAVE
$68.99
Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (A)
3 Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (C)

Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (C)

  • DURABLE DESIGN ENSURES LONGEVITY IN HIGH-HEAT WELDING ENVIRONMENTS.
  • EASY INSTALLATION MINIMIZES DOWNTIME AND BOOSTS WORKFLOW EFFICIENCY.
  • PROTECTS TIPS FROM WEAR, ENHANCING PERFORMANCE AND REDUCING COSTS.
BUY & SAVE
$19.98
Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (C)
4 WEN 23114 1.4-Amp High-Powered Variable Speed Rotary Tool with Cutting Guide, LED Collar, 100+ Accessories, Carrying Case and Flex Shaft

WEN 23114 1.4-Amp High-Powered Variable Speed Rotary Tool with Cutting Guide, LED Collar, 100+ Accessories, Carrying Case and Flex Shaft

  • 40% MORE POWER WITH A 1.4-AMP SPEED MOTOR FOR VERSATILE USE.

  • VERSATILE COLLARS FOR EFFICIENT DRILLING, ROUTING, AND DEBRIS DEFLECTION.

  • ORGANIZED STORAGE CASE WITH 100+ ACCESSORIES FOR ALL YOUR PROJECTS.

BUY & SAVE
$32.05
WEN 23114 1.4-Amp High-Powered Variable Speed Rotary Tool with Cutting Guide, LED Collar, 100+ Accessories, Carrying Case and Flex Shaft
5 Replacement PUF-CO Proxy Part Protectors for Replacement Parts PFC-P Accessories Welding Tips Accessories (white)

Replacement PUF-CO Proxy Part Protectors for Replacement Parts PFC-P Accessories Welding Tips Accessories (white)

  • DURABLE PUF-CO DESIGN ENHANCES PERFORMANCE AND LONGEVITY.
  • EASY INSTALLATION SAVES TIME AND BOOSTS OPERATIONAL EFFICIENCY.
  • COMPATIBLE WITH PFC-P ACCESSORIES FOR SEAMLESS INTEGRATION.
BUY & SAVE
$23.98
Replacement PUF-CO Proxy Part Protectors for Replacement Parts PFC-P Accessories Welding Tips Accessories (white)
6 Patelai 100 Pieces Braces Dental Brush for Cleaner Interdental Toothpick Dental Tooth Flossing Head Oral Hygiene Flosser Toothpick Cleaners Tooth Tool(Red,Suitable Size)

Patelai 100 Pieces Braces Dental Brush for Cleaner Interdental Toothpick Dental Tooth Flossing Head Oral Hygiene Flosser Toothpick Cleaners Tooth Tool(Red,Suitable Size)

  • 100 INTERDENTAL BRUSHES: ENOUGH FOR FAMILY USE & SHARING!

  • THOUGHTFUL DESIGN: SAFELY REMOVES DEBRIS & FRESHENS BREATH.

  • CONVENIENT & PORTABLE: IDEAL FOR HOME, OFFICE, OR TRAVEL!

BUY & SAVE
$8.49
Patelai 100 Pieces Braces Dental Brush for Cleaner Interdental Toothpick Dental Tooth Flossing Head Oral Hygiene Flosser Toothpick Cleaners Tooth Tool(Red,Suitable Size)
7 BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, White and Green)

BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, White and Green)

  • GET 100 INTERDENTAL BRUSHES FOR ALL YOUR ORAL CARE NEEDS DAILY!
  • EFFECTIVE PLAQUE REMOVAL AND FRESH BREATH WITH PRACTICAL DESIGN.
  • LIGHTWEIGHT, PORTABLE, AND PERFECT FOR HOME OR TRAVEL USAGE!
BUY & SAVE
$9.79
BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, White and Green)
8 BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, Green, Light Blue)

BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, Green, Light Blue)

  • 100 INTERDENTAL BRUSHES: AMPLE SUPPLY FOR DAILY ORAL CARE!
  • PRACTICAL DESIGN: EFFECTIVELY REMOVE PLAQUE AND FRESHEN BREATH!
  • PORTABLE & CONVENIENT: PERFECT FOR HOME, TRAVEL, OR GIFTS!
BUY & SAVE
$9.49
BBTO 100 Pcs Braces Dental Brush Flosser for Cleaner Interdental Brush Toothpick Tooth Flossing Head Oral Dental Toothpick Cleaners Cleaning Tool(Red, Blue, Green, Light Blue)
9 Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (ZGREY)

Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (ZGREY)

  • DURABLE DESIGN ENHANCES WELDING TIP LONGEVITY AND PERFORMANCE.
  • EASY INSTALLATION ENSURES QUICK MAINTENANCE AND REDUCED DOWNTIME.
  • COST-EFFECTIVE SOLUTION TO SAVE ON WELDING TIP REPLACEMENTS.
BUY & SAVE
$43.99
Replacement PUF-CO Proxy Part Protectors for Welding Tips Accessories (ZGREY)
+
ONE MORE?

To use a proxy in Selenium Python, you can follow the steps mentioned below:

  1. Import the necessary modules: from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType
  2. Set up the proxy: proxy = Proxy() proxy.proxy_type = ProxyType.MANUAL proxy.http_proxy = ":" proxy.ssl_proxy = ":" Note: Replace and with the actual proxy server address and port.
  3. Configure the desired capabilities: capabilities = webdriver.DesiredCapabilities.CHROME proxy.add_to_capabilities(capabilities)
  4. Launch the browser with the configured proxy: driver = webdriver.Chrome(desired_capabilities=capabilities) Replace Chrome with the appropriate browser (e.g., Firefox, Edge, etc.) if you are using a different browser.
  5. Proceed with your desired automated browser actions using the driver object.

By following the above steps, you can easily use a proxy with Selenium in Python for browsing with IP anonymity or accessing region-restricted content.

How to bypass proxy settings for local addresses in Selenium Python?

To bypass proxy settings for local addresses in Selenium Python, you can add a proxy capability to your WebDriver instance and exclude the local addresses from the proxy configuration. Here is an example:

from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType

Create a new Proxy object

proxy = Proxy()

Set the proxy type to MANUAL

proxy.proxy_type = ProxyType.MANUAL

Add the proxy server address and port

proxy.http_proxy = "127.0.0.1:8080"

Set the desired capabilities with proxy configuration

capabilities = webdriver.DesiredCapabilities.CHROME.copy() proxy.add_to_capabilities(capabilities)

Exclude the local addresses from the proxy configuration

proxy.add_to_capabilities({'proxy': {'noProxy': ''}})

Create a new WebDriver instance with the desired capabilities

driver = webdriver.Chrome(desired_capabilities=capabilities)

Now you can use the WebDriver instance for automation

...

In this example, we create a Proxy object and set its type to MANUAL. Then, we add the proxy server address and port to the proxy object. Next, we create a copy of the CHROME desired capabilities and add the proxy configuration to it using the add_to_capabilities method on the proxy object. Finally, we exclude the local addresses from the proxy configuration by adding {'proxy': {'noProxy': '<local>'}} to the capabilities. This ensures that any local addresses are accessed directly without going through the proxy.

How to use a proxy in Selenium Python?

To use a proxy in Selenium Python, you can follow these steps:

  1. Import the necessary modules:

from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType

  1. Create a Proxy object and specify the proxy server address and port:

proxy = Proxy() proxy.proxy_type = ProxyType.MANUAL proxy.http_proxy = "<proxy_server_address>:<proxy_port>" proxy.ssl_proxy = "<proxy_server_address>:<proxy_port>"

Replace <proxy_server_address> and <proxy_port> with the appropriate values.

  1. Create a webdriver.DesiredCapabilities object and set the proxy:

capabilities = webdriver.DesiredCapabilities.CHROME proxy.add_to_capabilities(capabilities)

  1. Instantiate the WebDriver with the capabilities:

driver = webdriver.Chrome(desired_capabilities=capabilities)

Now, Selenium will use the specified proxy for all subsequent browser interactions.

How to use proxies for multi-threaded web scraping in Selenium Python?

To use proxies for multi-threaded web scraping in Selenium Python, follow these steps:

  1. Import the required dependencies:

import threading from selenium import webdriver from selenium.webdriver.chrome.options import Options

  1. Create a function to initialize the Selenium WebDriver instance with proxy settings:

def init_driver(proxy): chrome_options = Options() chrome_options.add_argument('--proxy-server=%s' % proxy) driver = webdriver.Chrome(options=chrome_options) return driver

  1. Create a function to perform the scraping operations on a given thread:

def scrape_with_proxy(proxy): driver = init_driver(proxy)

# Perform scraping operations using the driver instance

driver.quit()
  1. Initialize a list of proxies to be used:

proxies = ['proxy1:port', 'proxy2:port', 'proxy3:port']

  1. Create a list to hold the thread instances:

threads = []

  1. Create and start the threads, passing the proxy from the list to each thread:

for proxy in proxies: thread = threading.Thread(target=scrape_with_proxy, args=(proxy,)) thread.start() threads.append(thread)

  1. Wait for all the threads to complete using the join() method:

for thread in threads: thread.join()

By using this approach, you can perform multi-threaded web scraping with different proxies using Selenium in Python. Each thread will have its own instance of the WebDriver with the specified proxy settings.