我正在使用带有python绑定的Selenium 2从我们合作伙伴的网站获取一些数据。但平均来说,我花了大约13秒钟才能执行此操作。
我正在寻找一种方法来禁用图像css和flash等。
我正在使用Firefox 3.6,并且还使用pyvirtualdisplay来防止打开firefox窗口。任何其他优化加速Firefox也将有所帮助。
我已经尝试过network.http。*选项,但不是很有帮助。
并设置permissions.default.image = 2
解决方法
我已经想出了一种方法来防止Firefox加载CSS,图像和Flash。
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile def disableImages(self): ## get the Firefox profile object firefoxProfile = FirefoxProfile() ## disable CSS firefoxProfile.set_preference('permissions.default.stylesheet',2) ## disable images firefoxProfile.set_preference('permissions.default.image',2) ## disable Flash firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so','false') ## Set the modified profile while creating the browser object self.browserHandle = webdriver.Firefox(firefoxProfile)
再次感谢@Simon和@ernie的建议。
原文地址:https://www.jb51.cc/css/219999.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。