'Selenium python : block third-party

I would like to block third party websites when I acess a website using selenium to avoid being slowed down while scraping (the same way as Umatrix does)

I've seen i could do something like this (I'm using Chrome):

driver.execute_cdp_cmd('Network.setBlockedURLs', {"urls": ["www.baidu.com"]}) driver.execute_cdp_cmd('Network.enable', {})

Instead of quoting each URL, can I specify "thirdparty" in a way or another ?



Solution 1:[1]

You can add ad blocker(extension) to chrome and use default chrome profile, it should block the ads

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Noice