【发布时间】:2014-01-16 21:40:19
【问题描述】:
我的目标是通过 Python 将 Adblock Plus 与 Selenium 一起使用。我已经能够让它加载扩展,但默认情况下它不包括默认过滤器“EasyList”。这是我目前所拥有的:
from selenium import webdriver
from time import sleep
ffprofile = webdriver.FirefoxProfile()
adblockfile = '/Users/username/Downloads/adblock_plus-2.4-tb+fx+an+sm.xpi'
ffprofile.add_extension(adblockfile)
ffprofile.set_preference("extensions.adblockplus.currentVersion", "2.4")
browser = webdriver.Firefox(ffprofile)
while(True):
browser.get("www.cnn.com")
sleep(5)
大部分代码都是从http://selenium-python.readthedocs.org/en/latest/faq.html 盗取的
【问题讨论】:
-
听起来好像超出了 Selenium 的范围,基本上你想更改扩展的设置。我怀疑这是否可以实现。
标签: python selenium firefox-addon adblock