Set proxy server with selenium and Chrome

ryy77 :

How can I use proxy server using selenium and google chrome? I attached the code and I'm not sure if this will change the actual proxy server.

# selenium imports
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import random

PROXY ="88.157.149.250:8080";


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
# //a[starts-with(@href, 'https://www.amazon.com/')]/@href
LINKS_XPATH = '//*[contains(@id,"result")]/div/div[3]/div[1]/a'
browser = webdriver.Chrome(executable_path="C:\\Users\Andrei\Downloads\chromedriver_win32\chromedriver.exe",
                           chrome_options=chrome_options)
browser.get(
    'https://www.amazon.com/s/ref=lp_11444071011_nr_p_8_1/132-3636705-4291947?rh=n%3A3375251%2Cn%3A%213375301%2Cn%3A10971181011%2Cn%3A11444071011%2Cp_8%3A2229059011')
links = browser.find_elements_by_xpath(LINKS_XPATH)
for link in links:
    href = link.get_attribute('href')
    print(href)

Hiten :
from selenium import webdriver

PROXY = "88.157.149.250:8080" # IP:PORT or HOST:PORT

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("http://google.com")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to set proxy for Chrome browser in selenium using Java code

How to set proxy authentication in PhantomJS using selenium?

How to set Proxy setting for Chrome in Selenium Java

Set Chrome's language using Selenium ChromeDriver

Passing SameSite Chrome Flags to Selenium remote server

How to set Proxy Authentication in seleniumWebdriver for Chrome Browser

how to set https proxy for selenium's webdriver?

Selenium Grid: set chrome *binary* path

how to set proxy server details on WebServiceTemplate

Set up proxy server for create react app

How to set proxy server for gradle?

how do I set a proxy server in my headless chrome request using Node JS Puppeteer

set proxy address with selenium chrome

Disable proxy via Python for Selenium with headless Chrome

How do you run headless chrome and a proxy using selenium in python?

curl set server address instead proxy

how to set proxy with authentication in selenium chromedriver python?

Can not set Luminati proxy on Selenium in Python 3

Set up proxy on selenium geckodriver

How to set preferences for Chrome in Selenium Python

Set up proxy server with multiple targets?

Failing to set up proxy for chrome in Selenium (Python 3.7)

Chrome extension background XMLHttpRequest proxy server

Changing the proxy server during Selenium

Set Proxy for Linux server by bash script failed

How to set nginx reverse proxy in remote server

Accessing a website behind a proxy server with Google Chrome headless, using Selenium, which works when using Fiddler

How to set the Proxy server in code for a RestClient API

Selenium - Set http proxy to the webdriver