简体   繁体   中英

Automate Chrome request blocking using Selenium-webdriver for python?

Can I automate Chrome request blocking using Selenium-webdriver for python? Python,Selenium,ChromeDriver,Chrome Devtool protocol.

1# from selenium import webdriver
2# driver = webdriver.Chrome()
3# driver.execute_cdp_cmd('Network.setBlockedURLs', {"urls": ["www.baidu.com"]})
4# driver.get("https://www.baidu.com")

It seems '3#' is inopreative. How can I modify above codes?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM