Whitelist domains Selenium / Firefox can connect to -
i using selenium webdriver firefox. wondering if there setting can change such requesting resources domains. (specifically want request content on same domain webpage itself).
my current set up, written in python, is:
selenium import webdriver firefox_profile = webdriver.firefoxprofile() ## here, change various default setting in firefox, , install couple of monitoring extensions driver = webdriver.firefox(firefox_profile) driver.get(web_address)
what want do, if specify web address wwww.domain.com
, load content served domain.com
, , not e.g. tracking content hosted other domains typically requested. hoping achieved change profile settings in firefox, or via extension.
note - there similar question (without answer) - restricting selenium/webdriver/htmlunit domain - 4 years old, , think selenium has evolved lot since then.
with vicky, (who's approach of using proxy settings followed - although directly selenium), code below change proxy settings in firefox such not connect domain except on white-list.
i suspect several setting changes unnecessary , can omitted purposes. code in python.
selenium import webdriver firefox_profile = webdriver.firefoxprofile() ## replace desired_domain.com below whitelisted domain. separate domains comma. firefox_profile.set_preference("network.proxy.no_proxies_on","localhost,127.0.0.1,desired_domain.com") firefox_profile.set_preference("network.proxy.backup.ftp","0.0.0.0") firefox_profile.set_preference("network.proxy.backup.ftp_port",1) firefox_profile.set_preference("network.proxy.backup.socks","0.0.0.0") firefox_profile.set_preference("network.proxy.backup.socks_port",1) firefox_profile.set_preference("network.proxy.backup.ssl","0.0.0.0") firefox_profile.set_preference("network.proxy.backup.ssl_port",1) firefox_profile.set_preference("network.proxy.ftp","0.0.0.0") firefox_profile.set_preference("network.proxy.ftp_port",1) firefox_profile.set_preference("network.proxy.http","0.0.0.0") firefox_profile.set_preference("network.proxy.http_port",1) firefox_profile.set_preference("network.proxy.socks","0.0.0.0") firefox_profile.set_preference("network.proxy.socks_port",1) firefox_profile.set_preference("network.proxy.ssl","0.0.0.0") firefox_profile.set_preference("network.proxy.ssl_port",1) firefox_profile.set_preference("network.proxy.type",1) firefox_profile.set_preference("network.proxy.share_proxy_settings",true) driver = webdriver.firefox(firefox_profile) driver.get(web_address_desired)
Comments
Post a Comment