0

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 ? Thanks

Kwinten
  • 11
  • 3
  • Does this answer your question? [Can I automate Chrome request blocking using Selenium-webdriver for Ruby?](https://stackoverflow.com/questions/46891301/can-i-automate-chrome-request-blocking-using-selenium-webdriver-for-ruby) – Vincent May 12 '22 at 22:28

1 Answers1

0

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

Noice
  • 11
  • 1
  • Yes I already did this, but i really want to be very specific, blocking all third party websites and not only ads detected by the adblocker – Kwinten May 03 '22 at 20:04