As we use user-agent or proxy-pool while scraping with scrapy, what tool should be used in case of selenium? And also want to know how to use. Can anyone help me with this issue?
1 Answer
When running Selenium with FireFox you can specify the proxy settings for the driver. The following is Python specific code for setting FireFox proxy settings.
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
with webdriver.Firefox() as driver:
# Open URL
driver.get("https://selenium.dev")
Check out selenium https proxy documentation for other languages.
For Chrome you can do something similar and pass in options for the browser:
from selenium import webdriver
PROXY = "<HOST:PORT>"
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(chrome_options=options')
driver.get("https://selenium.dev")