selenium+phantomjs实现网页截图

1、安装 selenium

PS C:\WINDOWS\system32> pip install selenium
Collecting selenium
  Downloading https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl (904kB)
    100% |████████████████████████████████| 911kB 348kB/s
Requirement already satisfied: urllib3 in c:\program files\python37\lib\site-packages (from selenium) (1.24.1)
Installing collected packages: selenium
Successfully installed selenium-3.141.0

2、下载phantomjs

3、安装(解压)

4、配置环境变量

  • C:\Program Files\phantomjs\bin

5、测试

from selenium import webdriver
print("start....\n")
driver = webdriver.PhantomJS(executable_path=r"C:\Program Files\phantomjs\bin\phantomjs.exe")
#phantomjs安装的位置
url='https://www.baidu.com/'
driver.get(url)
driver.save_screenshot("baidu.png")
print("ok!\n")

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值