Python无法识别Selenium中的幻影

2024-09-26 22:10:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我开始学习web抓取,所以我尝试在Python中使用PhantomJS。过了几个小时ghostdriver.log障碍我现在碰到了一个名称错误:全局名“PhantomJS”没有定义

我在Windows10机器上工作,有phantomjs 2.1.1和metaperl::selenium 2.40.0(这和selenium不同吗?)在

我的代码是:

import selenium as sel  #i don't think this was needed, but i was trying anything
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.PhantomJS(executable_path='~/Downloads/phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin')
driver.set_window_size(1024, 768) 
driver.get('https://www.google.com/#q=data+science')

完整异常消息:

^{pr2}$

我尝试过使用路径名,在代码之外设置可执行路径,阅读selenium和phantomjs的文档,并在web上搜索了几个小时,以寻找我能弄清楚它到底是怎么回事的任何东西。在


Tags: 代码fromimportlogwebwindowsdriverselenium

热门问题