def screenshot(team_id=None, channel=None, params=[]): url = params.pop(0).replace('<', '').replace('>', '') # fix extra chars added by Slack delay = Misc.to_int(Misc.array_pop(params,0)) slack_message(":point_right: taking screenshot of url: {0}".format(url),[], channel,team_id) browser_helper = Browser_Lamdba_Helper().setup() png_data = browser_helper.get_screenshot_png(url,full_page=True, delay=delay) return browser_helper.send_png_data_to_slack(team_id,channel,url, png_data)
def run(event, context=None): headless = event.get('headless', True) url = event.get('url') delay = event.get('delay') js_code = event.get('js_code') browser_helper = Browser_Lamdba_Helper(headless).setup() png_data = browser_helper.get_screenshot_png(url=url, full_page=True, delay=delay, js_code=js_code) return png_data
def screenshot(team_id=None, channel=None, params=None): params = params or [] try: url = None if len(params) > 0: url = params.pop(0).replace('<', '') \ .replace('>', '') # fix extra chars added by Slack and the u00a0 unicode char. if url == '_': # special mode to not render url = None else: message = ":point_right: taking screenshot of url: {0}".format( url) if url is None: message = ':point_right: no url provided, so showing what is currently on the browser' width = to_int(Misc.array_pop(params, 0)) height = to_int(Misc.array_pop(params, 0)) delay = to_int(Misc.array_pop(params, 0)) if width: message += ", with width `{0}`".format(width) if height: message += ", with height `{0}` (min height)".format(height) if delay: message += ", with delay of `{0}` seconds".format(delay) slack_message(message, [], channel) browser_helper = Browser_Lamdba_Helper().setup() if width: browser_helper.api_browser.sync__browser_width(width, height) png_data = browser_helper.get_screenshot_png(url, full_page=True, delay=delay) slack_message( f':point_right: got screenshot of size {len(png_data)}, sending it to Slack...', [], channel) return browser_helper.send_png_data_to_slack( team_id, channel, url, png_data) except Exception as error: import traceback message = f':red_circle: Browser Error: {error} \n {traceback.format_exc()}' #message = f':red_circle: Browser Error: {error}' return slack_message(message, [], channel, team_id)
def run(event, context): url = event.get('url') if url: from osbot_browser.browser.Browser_Lamdba_Helper import Browser_Lamdba_Helper browser = Browser_Lamdba_Helper().setup() return browser.get_screenshot_png(url)