PhantomJS.exe
文件路径path
browser = webdriver.PhantomJS(path)
browser.get(url)
扩展: 保存屏幕快照:browser.save_screenshot('baidu.png')
示例:
from selenium import webdriver
# 主要是引入这里和Selenium不一样,其他都一样
path = 'phantomjs.exe'
browser = webdriver.PhantomJS(path)
# 打开网站
url = 'https://www.baidu.com'
browser.get(url)
# 抓图
browser.save_screenshot('baidu.png')
import time
time.sleep(2)
# 百度搜索框输入PhantomJS
input = browser.find_element_by_id('kw')
input.send_keys('PhantomJS')
time.sleep(3)
# 抓图
browser.save_screenshot('PhantomJS.png')
注意:Phantomjs已停止开发。请移步
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有