Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用python将Selenium屏幕截图保存到数据库_Python_Database_Selenium_Selenium Webdriver_Screenshot - Fatal编程技术网

用python将Selenium屏幕截图保存到数据库

用python将Selenium屏幕截图保存到数据库,python,database,selenium,selenium-webdriver,screenshot,Python,Database,Selenium,Selenium Webdriver,Screenshot,使用selenium web驱动程序拍摄web截图时,它正确地保存了PNG截图。那么,有没有办法将这些PNG截图直接存储在数据库中?目前我使用下面的代码 options = webdriver.ChromeOptions() options.headless = True driver = webdriver.Chrome('C:/Users/admin/Desktop/chromedriver.exe', options=options) driver.get(response.url)

使用selenium web驱动程序拍摄web截图时,它正确地保存了PNG截图。那么,有没有办法将这些PNG截图直接存储在数据库中?目前我使用下面的代码

options = webdriver.ChromeOptions()
options.headless = True
driver = webdriver.Chrome('C:/Users/admin/Desktop/chromedriver.exe', options=options)

driver.get(response.url)

S = lambda X: driver.execute_script('return document.body.parentNode.scroll'+X)
driver.set_window_size(S('Width'),S('Height')) # May need manual adjustment                                                                                                                
driver.find_element_by_tag_name('body').screenshot('./images/sample.png')

什么样的数据库?您可以将其保存为Blob。什么类型的数据库?您可以将其保存为一个Blob。