您应该可以使用https://github.com/jarib/browsermob-proxy-rb上的 browsermob-proxy-rb gem 将您的 CDN 列入黑名单。
以下内容大部分是从 github 列表的 README 中窃取的:
require 'selenium/webdriver'
require 'browsermob/proxy'
server = BrowserMob::Proxy::Server.new("/path/to/download/browsermob-proxy") #=> #<BrowserMob::Proxy::Server:0x000001022c6ea8 ...>
server.start
proxy = server.create_proxy #=> #<BrowserMob::Proxy::Client:0x0000010224bdc0 ...>
profile = Selenium::WebDriver::Firefox::Profile.new #=> #<Selenium::WebDriver::Firefox::Profile:0x000001022bf748 ...>
# This is the line I added
proxy.blacklist(/path.to.CDN.com/)
profile.proxy = proxy.selenium_proxy
driver = Selenium::WebDriver.for :firefox, :profile => profile
driver.get "http://www.yoursite.com"