I am doing web-scraping with selenium/geckodriver on windows machine. My create_driver function defines a specific Firefox profile:
def create_driver()
firefox_profile = webdriver.FirefoxProfile() # Disable CSS
firefox_profile.set_preference('permissions.default.stylesheet', 2) # Disable images
firefox_profile.set_preference('permissions.default.image', 2) # Disable Flash
driver = webdriver.Firefox(firefox_profile=firefox_profile) # Create driver
return driver
driver = create_driver()
However, for every run Firefox creates a new, 400 KB profile file in C:/User/Appdata/Local/temp
(tmpaddon-xxxxxx, see picture below):
This obviously creates significant overhead that I need to get rid of. I know that profiles can be created manually using Firefox Profile Manager. Those can then be used with selenium like explained here. However, I did not figure out yet how to create & populate those profile files using python.
Q1: How to save and reuse one Firefox profile with specs that have been defined in python to disk?
Q2: How to prevent Firefox from auto-saving a profile once every driver instance runs?