File size: 1,203 Bytes
720f322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
#from selenium_webdriver import WebElement
import uuid

driver_type = 'chromedriver'
driver=False

def create_ss(graph):
    uid=uuid.uuid4()
    code_out=""
    for ea in graph.split("\n"):
        code=ea.strip().strip("\n")
        code_out+=code
    url=f"https://omnibus-text-to-chart.hf.space/file=merm.html?mermaid={code_out}"
    is_url=True
    wait_time=10000
    if is_url:
        options = webdriver.ChromeOptions()
        options.add_argument('--headless')
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')
        mes='<center>operation success'
        try:
            driver = webdriver.Chrome(options=options)
            driver.get(url)
            html=driver.page_source
            print(html)            
            driver.implicitly_wait(int(wait_time*30))
            driver.set_window_size(int(width), int(height))
            obj = driver.find_element(By.ID, "chart_box")            
            screenshot = obj.screenshot(f'{uid}-tmp.png')
    return(f'{uid}-tmp.png')