0

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 1

1

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.