python使用selenium无界面浏览器

#coding=utf-8
import selenium
import selenium.webdriver
import time

path = r"D:\Program Files\phantomjs-2.1.1-windows\bin\phantomjs.exe"
webdriver = selenium.webdriver.PhantomJS(path)
webdriver.get('https://baidu.com')
time.sleep(3)
webdriver.save_screenshot('baidu.jpg')
print(webdriver.page_source)
webdriver.quit()

你可能感兴趣的:(python使用selenium无界面浏览器)