使用phantomjs时,selenium提示phantomjs被标记为不赞成使用,推荐使用Headless Chrome

  • 安装selenium
pip install selenium

#!/usr/bin/env python3
#--coding:utf-8--
author = ‘xiaobing’
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url = “https://www.ywcsb.vip”
chrome_options = Options()
chrome_options.add_argument(‘–headless’)
chrome_driver = webdriver.Chrome(
    executable_path=r”D:\chromedriver_win32\chromedriver.exe”,
    chrome_options=chrome_options
)
chrome_driver.get(url)
chrome_driver.save_screenshot(“screenshot.png”)
chrome_driver.close()