Blacklist and whitelist URLs in HtmlUnitDriver
问题 Blacklisting URLs in PhantomJS and GhostDriver is pretty straightforward. First initialize the driver with a handler: PhantomJSDriver driver = new PhantomJSDriver(); driver.executePhantomJS(loadFile("/phantomjs/handlers.js")) And configure the handler: this.onResourceRequested = function (requestData, networkRequest) { var allowedUrls = [ /https?:\/\/localhost.*/, /https?:\/\/.*\.example.com\/?.*/ ]; var disallowedUrls = [ /https?:\/\/nonono.com.*/ ]; function isUrlAllowed(url) { function