Selenium+PhantomJS

Posted 马拉猪的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章

selenium是啥?

Python爬虫 Selenium -- Selenium元素定位Selenium访问元素信息Selenium交互

Selenium学习Selenium 总结

Selenium - 简介

java selenium selenium 介绍

selenium3降版为selenium2