Python对网页截图

作者: cayman 分类: 未分类 发布时间: 2017-03-14 15:16

采用方案:Python + Selenium+phantomjs

可以针对默写元素进行截图

driver.get_screenshot_as_file() 路径加位置

 

 

driver = webdriver.Chrome()
driver.get('http://stackoverflow.com/')
driver.save_screenshot('screenshot.png')

left = element.location['x']
top = element.location['y']
right = element.location['x'] + element.size['width']
bottom = element.location['y'] + element.size['height']

im = Image.open('screenshot.png') 
im = im.crop((left, top, right, bottom))
im.save('screenshot.png')

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注