首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PhantomJS -拒绝许可

PhantomJS -拒绝许可
EN

Stack Overflow用户
提问于 2015-07-19 00:09:26
回答 1查看 2.2K关注 0票数 2

我正在使用Selenium和PhantomJS与我正在编写的Python,并且我在通过脚本启动PhantomJS服务时遇到了困难,我一直收到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "asp_scraper.py", line 59, in <module>
    scraper = DanishScraper()
  File "asp_scraper.py", line 20, in __init__
    self.driver = webdriver.PhantomJS(executable_path='./phantomjs/bin/phantomjs')
  File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 53, in __init__
    self.service.start()
  File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/service.py", line 84, in start
    raise WebDriverException("Can not connect to GhostDriver")
selenium.common.exceptions.WebDriverException: Message: Can not connect to GhostDriver

到目前为止,我的应用程序就是这样的:

代码语言:javascript
复制
import re
import string
import urlparse

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, WebDriverException
from bs4 import BeautifulSoup

class DanishScraper(object):
  def __init__(self):
      self.url = "http://www.realtor.ca/RealtorSearch.aspx"
      self.driver = webdriver.PhantomJS(executable_path='./phantomjs/bin/phantomjs')
      self.driver.set_window_size(1120, 550)



  def scrape(self):
    self.driver.get(self.url)

    # Select state selection dropdown
    select = Select(self.driver.find_element_by_id('ProvinceIds'))
    option_indexes = range(1, len(select.options))

    for index in option_indexes:
      select.select_by_index(index)
      self.driver.find_element_by_id
    print option_indexes

if __name__ == '__main__':
scraper = DanishScraper()
scraper.scrape()

它可能与可执行文件的位置有关吗?我正在MacOS10.11 (El Capitan)上运行Python2.7。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-19 02:01:51

我在Mac上也有类似的症状。安装从PhantomJS下载的修补程序的这里二进制文件帮助我解决了这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31496772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档