I want to make visiting websites much faster with Selenium. Does someone know, What I can do here? I already know that I should switch off Javascript or images, for example, but what else is there?
Here is my code. You can ignore the fact that I am using the Tor Browser (that is why it is very slow):
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
torexe = os.popen(r'C:\Users\Max\Desktop\Tor_Browser\Browser\TorBrowser\Tor\tor.exe')
profile = FirefoxProfile(r'C:\Users\Max\Desktop\Tor_Browser\Browser\TorBrowser\Data\Browser\profile.default')
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
profile.set_preference("network.proxy.socks_remote_dns", True)
profile.set_preference("browser.download.folderList",2)
profile.set_preference("javascript.enabled", False)
browser = webdriver.Firefox(firefox_profile=profile, executable_path=r'C:\Users\Kinder\Downloads\geckodriver-v0.27.0-win64\geckodriver.exe')
browser.get("https://check.torproject.org/")
Can anyone give me a code to put in there? Thanks
Try to use threading
, to leverage multiple CPU. The result will be multiple open selenium independent windows which cannot communicate with each other but you will be going through multiple parallel Tor circuits which will improve speed.
From python point of view, you have done everything possible to speed up loading pages.
These are circuits which are slowing you down. Needless to say, the speed effect will scale with more circuits and Tor browser windows opened.