Screenshot of Streamlit app

Hi!

First of all thanks for offering this amazing Streamlit service!

I would like to share an issue I am experiencing and ask for some help. I understand it is probably more a web-scraping question, nevertheless, I thought others in the Streamlit community might have experienced the same problem.

The script below (which I found here) is used to take a screenshot of a private Streamlit web-app running on an AWS EC2 instance.

from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = webdriver.ChromeOptions()
options.headless = True
driver = webdriver.Chrome(options=options)
URL = 'http://<ADDRESS>:<PORT>/'

driver.get(URL)
sleep(1)
S = lambda X: driver.execute_script('return document.body.parentNode.scroll'+X)
driver.set_window_size(S('Width'),S('Height'))
                                                                                                            driver.find_element_by_tag_name('body').screenshot('screenshot.png')

driver.quit()

The script creates the .png file but it is not a full-page screenshot. The image file simply shows the top of the page, the width seems the correct one but the height is too small (the dimension is 2400 × 26…)
How can I get the screenshot showing the full content of the webpage?
Thanks!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.