Python 2.7 Python 2.7、Selenium和PhantomJS错误
我安装了Selenium v2.7和PhantomJS v2.1。PhantomJS在我的命令提示符下运行,但在我的程序中不起作用Python 2.7 Python 2.7、Selenium和PhantomJS错误,python-2.7,selenium,phantomjs,Python 2.7,Selenium,Phantomjs,我安装了Selenium v2.7和PhantomJS v2.1。PhantomJS在我的命令提示符下运行,但在我的程序中不起作用 from selenium import webdriver driver = webdriver.PhantomJS() driver.add_cookie({'PHPSESSID': '<mysessionid>'}) driver.get("http://csgodouble.com/") print(driver.find_element_b
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.add_cookie({'PHPSESSID': '<mysessionid>'})
driver.get("http://csgodouble.com/")
print(driver.find_element_by_xpath('//div[@class="past"]').text)
print driver.current_url
从selenium导入webdriver
driver=webdriver.PhantomJS()
添加cookie({'PHPSESSID':''})
驱动程序。获取(“http://csgodouble.com/")
打印(driver.find_element_by_xpath('//div[@class=“pass”]”)text)
打印driver.current\u url
当我运行程序时,它会输出错误:
driver=webdriver.PhantomJS()
AttributeError:“module”对象没有属性“PhantomJS”
我该如何解决这个问题?谢谢,您的前两行代码基本上很好,但据我所知,2012年12月,PhantomJS支持没有添加到Selenium Python中 因此,如果
pip
说您有selenium
模块的2.7.0版(从2011年9月开始),您需要做的就是升级到最新版本(2.52.0)
pip卸载selenium
然后:
pip安装-U selenium
()您可以运行pip list | grep selenium
?还有,phantomjs
在你的路径上吗?@AndrewRegan我在Windows8.1上,没有grep。PhantomJS在我的Pathk上,您从pip列表中获得的selenium版本(我应该说这对我很有用)我有selenium(2.7.0)和Python 2.7