Python/Selenium: How can I emulate extensions such as uBlock or AdBlock using a headless Chrome driver? Python/Selenium: How can I emulate extensions such as uBlock or AdBlock using a headless Chrome driver? selenium selenium

Python/Selenium: How can I emulate extensions such as uBlock or AdBlock using a headless Chrome driver?


As extensions are not supported in headless mode, Proxy servers seem to be the best possible course of action here.

You can try using https://github.com/epitron/mitm-adblock to setup a local proxy server (written in python and easy to set up) and add --proxy-server=localhost:8118 when starting up chrome. It supports AdblockPlus easylist which should be fairly comprehensive.

You can also try https://github.com/Artificial-University/adblock-proxy which is written in node but seems more full-fledged and recently updated.