使用phantomjs时,selenium提示phantomjs被标记为不赞成使用,推荐使用Headless Chrome
- 安装selenium
pip install selenium
下载 WebDriver for Chrome 下载地址 https://sites.google.com/a/chromium.org/chromedriver/downloads 链接:https://pan.baidu.com/s/1_UBf5-Pt2wXXdjpdJGGMvg 密码:sm85
测试代码
#!/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()
发表评论
共 0 条评论
暂无评论