Omnibus commited on
Commit
720f322
·
verified ·
1 Parent(s): 677539d

Create screenshot.py

Browse files
Files changed (1) hide show
  1. screenshot.py +34 -0
screenshot.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from selenium.common.exceptions import WebDriverException
2
+ from selenium.webdriver.common.keys import Keys
3
+ from selenium.webdriver.common.by import By
4
+ #from selenium_webdriver import WebElement
5
+ import uuid
6
+
7
+ driver_type = 'chromedriver'
8
+ driver=False
9
+
10
+ def create_ss(graph):
11
+ uid=uuid.uuid4()
12
+ code_out=""
13
+ for ea in graph.split("\n"):
14
+ code=ea.strip().strip("\n")
15
+ code_out+=code
16
+ url=f"https://omnibus-text-to-chart.hf.space/file=merm.html?mermaid={code_out}"
17
+ is_url=True
18
+ wait_time=10000
19
+ if is_url:
20
+ options = webdriver.ChromeOptions()
21
+ options.add_argument('--headless')
22
+ options.add_argument('--no-sandbox')
23
+ options.add_argument('--disable-dev-shm-usage')
24
+ mes='<center>operation success'
25
+ try:
26
+ driver = webdriver.Chrome(options=options)
27
+ driver.get(url)
28
+ html=driver.page_source
29
+ print(html)
30
+ driver.implicitly_wait(int(wait_time*30))
31
+ driver.set_window_size(int(width), int(height))
32
+ obj = driver.find_element(By.ID, "chart_box")
33
+ screenshot = obj.screenshot(f'{uid}-tmp.png')
34
+ return(f'{uid}-tmp.png')