首页 > 代码库 > Selenium+PhantomJS

Selenium+PhantomJS

from selenium import webdriver
import time
import os


path = os.path.dirname(__file__)
# print(path)
driver = webdriver.PhantomJS(executable_path=‘C:/Insert/phantomjs-2.1.1-windows/bin/phantomjs‘)
driver.get(‘http://pythonscraping.com/pages/javascript/ajaxDemo.html‘)
time.sleep(8)
print(driver.find_element_by_id(‘content‘).text)
driver.close()

问题 ‘Service‘ object has no attribute ‘process‘

其实就是你的浏览器可执行文件的路径没写对

Selenium+PhantomJS