Disable Images in Selenium and Browserist#
Why Disable Images? Advantages and Disadvantages#
If you want to scrape a website that loads images, you can gain a performance boost by disabling images.
This is often done in combination with headless mode, since you can't see any graphics in a headless browser. On the other hand, the disadvantage is obviously that you can't observe what the browser is doing.
How to Configure#
Selenium#
With Selenium, each browser type has its own configuration:
Python | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 |
|
Python | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Python | |
---|---|
1 2 3 4 5 6 7 8 |
|
Browserist#
Or use Browserist where the configuration is the same for all browser types βΒ less hassle as the configuration of Selenium is automatically handled in the background. Simply set disable_images=True
in the BrowserSettings
class:
Python | |
---|---|
1 2 3 4 5 6 7 8 9 10 |
|
Supported Browsers#
Note
Not all browsers support disabling of images well: Both Safari and Internet Explorer requires us to update global settings in the operating system that may impact how these browsers behave outside Browserist.
Browsers that support disabling of images:
Chrome | Edge | Firefox | Safari | Internet Explorer |
---|---|---|---|---|