src/screenshot.py
def screenshot(url: str, configuration: dict = {}) -> str:
    """
    Screenshots a url website

    url : str
        The url from which to get a Screenshot
    configuration : dict
        The configuration object

    returns str
    """

    # Merge the two dicitionaries
    configuration = { **default_configuration, **configuration }

    # Generate the target path
    uniqueid = unique_id()
    taret_dir = os.path.join(basedir, 'screenshots')
    if not os.path.exists(taret_dir): os.mkdir(taret_dir)

    target_path = os.path.join(taret_dir, f'{uniqueid}.png')

    chrome_options = Options()
    chrome_options.add_argument("--headless")
    browser = webdriver.Chrome(CHROME_DRIVER, options=chrome_options)
    browser.get(url)

    # Set the size, if the dimensions are given
    if ('width' in configuration) & ('height' in  configuration):
        browser.set_window_size(configuration['width'], configuration['height'])

    # Wether it could be saved or not
    screenshot = browser.save_screenshot(target_path)
    browser.quit()

    return target_path

    Screenshots a url website

    url : str
        The url from which to get a Screenshot
    configuration : dict
        The configuration object

    returns str
    
Screenshots a url website
url : str
The url from which to get a Screenshot
configuration : dict
The configuration object

returns str
Screenshots a url website url : str The url from which to get a Screenshot configuration : dict The configuration object returns str
def screenshot(url: str, configuration: dict = {}) -> str:
    configuration = { **default_configuration, **configuration }
    uniqueid = unique_id()
    taret_dir = os.path.join(basedir, 'screenshots')
    if not os.path.exists(taret_dir): os.mkdir(taret_dir)
    target_path = os.path.join(taret_dir, f'{uniqueid}.png')
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    browser = webdriver.Chrome(CHROME_DRIVER, options=chrome_options)
    browser.get(url)
    if ('width' in configuration) & ('height' in  configuration):
        browser.set_window_size(configuration['width'], configuration['height'])
    screenshot = browser.save_screenshot(target_path)
    browser.quit()
    return target_path
def screenshot ( url : str , configuration : dict = { } ) -> str : configuration = { ** default_configuration , ** configuration } uniqueid = unique_id ( ) taret_dir = os . path . join ( basedir , 'screenshots' ) if not os . path . exists ( taret_dir ) : os . mkdir ( taret_dir ) target_path = os . path . join ( taret_dir , f'{uniqueid}.png' ) chrome_options = Options ( ) chrome_options . add_argument ( "--headless" ) browser = webdriver . Chrome ( CHROME_DRIVER , options = chrome_options ) browser . get ( url ) if ( 'width' in configuration ) & ( 'height' in configuration ) : browser . set_window_size ( configuration [ 'width' ] , configuration [ 'height' ] ) screenshot = browser . save_screenshot ( target_path ) browser . quit ( ) return target_path
Screenshots a url website
url : str
The url from which to get a Screenshot
configuration : dict
The configuration object
Screenshots a url website url : str The url from which to get a Screenshot configuration : dict The configuration object
"""
    Screenshots a url website

    url : str
        The url from which to get a Screenshot
    configuration : dict
        The configuration object

    returns str
    """ # Merge the two dicitionaries # Generate the target path # Set the size, if the dimensions are given # Wether it could be saved or not
url
str
configuration
dict