from selenium import webdriver
def take_screenshot(url, file_path):
driver = webdriver.Chrome()
driver.get(url)
driver.save_screenshot(file_path)
driver.quit()
if __name__ == '__main__':
take_screenshot('http://baidu.com', 'D:\桌面\wang.png')
要安装selenium还要安装google的驱动