如何在Python中使用Selenium
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在Python中使用Selenium相关的知识,希望对你有一定的参考价值。
不知道你是linux 还是 windows 两种通用的方法可用命令直接自动安装如果你安装了pip 使用命令:pip install selenium
如果你安装了setuptools 使用命令:easy_install selenium
如果你两个都没装 建议你装一下 因为以后用的话会很方便 很好装的
把这个下载下来 解压之后 用命令cd到该文件夹下 运行命令:python setup.py install
不是很新的版本 你可以去官网上下载最新版本的来用! 参考技术A 网上有很多例子。。
如何在 Python 中使用 Selenium 在 Firefox 中禁用 Flash?
【中文标题】如何在 Python 中使用 Selenium 在 Firefox 中禁用 Flash?【英文标题】:How to disable Flash in Firefox with Selenium in Python? 【发布时间】:2013-04-30 16:17:55 【问题描述】:尝试使用配置文件设置在 Python 中使用 Selenium 在 Firefox 中禁用 Flash。 This question 指定了一种通过 GUI 执行此操作的方法,但对于此特定用例,以编程方式执行此操作会更好。具体来说,最好的解决方案是允许在新创建的配置文件对象中禁用 Flash。
非常感谢!
【问题讨论】:
【参考方案1】:您可以使用以下配置文件禁用闪光灯。
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
def disableImages(self):
## Firefox profile object
firefoxProfile = FirefoxProfile()
## 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)
【讨论】:
优秀。非常感谢! 您能否指定更多细节,例如 FF 和 selenium 版本?以上是关于如何在Python中使用Selenium的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Python 中使用 Selenium 在 Firefox 中禁用 Flash?
如何在 python 中使用 selenium 下载 pdf 文件
如何使用Selenium和Python在网站内的页面中导航?
如何使用 Selenium 和 Python 在控制台中跳过调试日志