网络编程
位置:首页>> 网络编程>> Python编程>> Windows系统下PhantomJS的安装和基本用法

Windows系统下PhantomJS的安装和基本用法

作者:回忆不说话  发布时间:2022-03-30 11:49:52 

标签:python,phantomjs

1.安装

下载网址:http://phantomjs.org/download.html

Windows系统下PhantomJS的安装和基本用法

选择合适的版本。然后解压即可。

环境变量的配置:

Windows系统下PhantomJS的安装和基本用法

进入解压的路径:

例如我是解压在D:\Python\phantomjs-2.1.1-windows\bin,将这个路径编辑在上图的末尾。就可以使用了。

如果刚配置好,在使用的时候,提示环境变量没有配置好的话,不妨重启一下电脑试试。

2 基本用法

引入:


from selenium import webdriver
# 使用webkit * 面浏览器
driver = webdriver.PhantomJS(executable_path=r'D:/Python/phantomjs-2.1.1-windows/bin/phantomjs.exe')

‘driver'的作用,去除里面的特殊字符的影响。


# 获取指定网页的数据
driver.get('http://news.sohu.com/scroll/')
print(driver.find_element_by_class_name('title').text)

来源:https://blog.csdn.net/qq_39138295/article/details/81542281

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com