Answer the question
In order to leave comments, you need to log in
How to make Selenium work with all types of proxies?
browser_options = Options()
browser_options.add_argument('--proxy-server=socks4://%s' % proxy)
Answer the question
In order to leave comments, you need to log in
For proxy use seleniumwire
from seleniumwire import webdriver
from fake_useragent import UserAgent
from selenium.webdriver import FirefoxProfile
seleniumwire_options = {
'proxy': {
'http': f'http://'
f'{proxy_data["username"]}:{proxy_data["password"]}@'
f'{proxy_data["proxy_address"]}:{proxy_data["ports"]["socks5"]}',
'https': f'https://'
f'{proxy_data["username"]}:{proxy_data["password"]}@'
f'{proxy_data["proxy_address"]}:{proxy_data["ports"]["socks5"]}',
'no_proxy': 'localhost,127.0.0.1,dev_server:8080'
}
}
profile = FirefoxProfile()
user_agent = UserAgent().random
profile.set_preference("general.useragent.override", user_agent)
options = Options()
options.add_argument('--headless')
driver = webdriver.Firefox(
firefox_profile=profile,
options=options,
seleniumwire_options=seleniumwire_options
)
driver.get('http://<your_url>')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question