Omnibus commited on
Commit
b4637d2
·
verified ·
1 Parent(s): 988a321

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -30,12 +30,12 @@ def get_concat_v_cut(in1, in2):
30
  dst = Image.new(
31
  'RGB', (min(im1.width, im2.width), im1.height + im2.height))
32
  dst.paste(im1, (0, 0))
33
- dst.paste(im2, (0, im1.height+10))
34
  return dst
35
 
36
 
37
 
38
- def run_script(url: str, height: int, width: int):
39
  mes_box=[]
40
  out_box=[]
41
  uid=uuid.uuid4()
@@ -56,23 +56,35 @@ def run_script(url: str, height: int, width: int):
56
  page = driver.find_element(By.TAG_NAME, "html")
57
  print (dir(page))
58
  print (page.text)
59
- driver.execute_script("arguments[0].theme = '';",page)
60
- #driver.execute_script("arguments[0].theme = 'gab-black';",page)
61
  main_head = driver.find_element(By.CLASS_NAME, "main-content-header")
62
  head_shot = main_head.screenshot(f'head-{uid}-tmp.png')
63
 
64
  obj = driver.find_element(By.CLASS_NAME, "main")
65
  messages = driver.find_elements(By.CLASS_NAME, "message")
66
  print (len(messages))
 
 
 
 
 
 
 
 
 
 
 
 
67
  for i,mes in enumerate(messages):
68
  print (mes.text)
69
  if not (i%2):
70
  messages[i].screenshot(f'{i}-{uid}-tmp.png')
71
  messages[i+1].screenshot(f'{i+1}-{uid}-tmp.png')
 
72
  out_box.append(get_concat_v_cut(f'{i}-{uid}-tmp.png',f'{i+1}-{uid}-tmp.png'))
73
  print(f'out_box:: {out_box}')
74
  #mes_box.clear()
75
-
76
  #obj = driver.find_element(By.ID, "app-container")
77
  #obj = driver.find_element(By.ID, "conversation-feed")
78
  #obj = driver.find_element_by_id("in_html")
@@ -115,6 +127,7 @@ with gr.Blocks() as app:
115
 
116
  with gr.Column():
117
  with gr.Row():
 
118
  height=gr.Number(label="Height", value=4096)
119
  width=gr.Number(label="Width",value=800)
120
  message=gr.HTML('<center>Enter URL')
@@ -123,5 +136,5 @@ with gr.Blocks() as app:
123
  outgal=gr.Gallery()
124
  outim = gr.Image()
125
 
126
- btn.click(run_script,[inp,height,width],[outim,message,outgal])
127
  app.launch()
 
30
  dst = Image.new(
31
  'RGB', (min(im1.width, im2.width), im1.height + im2.height))
32
  dst.paste(im1, (0, 0))
33
+ dst.paste(im2, (0, im1.height))
34
  return dst
35
 
36
 
37
 
38
+ def run_script(url: str, height: int, width: int, check_b):
39
  mes_box=[]
40
  out_box=[]
41
  uid=uuid.uuid4()
 
56
  page = driver.find_element(By.TAG_NAME, "html")
57
  print (dir(page))
58
  print (page.text)
59
+ driver.execute_script("arguments[0].style.background = 'blue';",page)
 
60
  main_head = driver.find_element(By.CLASS_NAME, "main-content-header")
61
  head_shot = main_head.screenshot(f'head-{uid}-tmp.png')
62
 
63
  obj = driver.find_element(By.CLASS_NAME, "main")
64
  messages = driver.find_elements(By.CLASS_NAME, "message")
65
  print (len(messages))
66
+ mes_blocks=len(messages)%2
67
+
68
+ for ea in check_b:
69
+ ea = int(ea)
70
+ ea = (ea*2)-1
71
+ print (ea)
72
+ messages[ea].screenshot(f'{ea}-{uid}-tmp.png')
73
+ messages[ea+1].screenshot(f'{ea+1}-{uid}-tmp.png')
74
+ out_box.append(get_concat_v_cut(f'{ea}-{uid}-tmp.png',f'{ea+1}-{uid}-tmp.png'))
75
+ print(f'out_box:: {out_box}')
76
+ #mes_box.clear()
77
+ '''
78
  for i,mes in enumerate(messages):
79
  print (mes.text)
80
  if not (i%2):
81
  messages[i].screenshot(f'{i}-{uid}-tmp.png')
82
  messages[i+1].screenshot(f'{i+1}-{uid}-tmp.png')
83
+ mes_box.append(())
84
  out_box.append(get_concat_v_cut(f'{i}-{uid}-tmp.png',f'{i+1}-{uid}-tmp.png'))
85
  print(f'out_box:: {out_box}')
86
  #mes_box.clear()
87
+ '''
88
  #obj = driver.find_element(By.ID, "app-container")
89
  #obj = driver.find_element(By.ID, "conversation-feed")
90
  #obj = driver.find_element_by_id("in_html")
 
127
 
128
  with gr.Column():
129
  with gr.Row():
130
+ check_b=gr.CheckboxGroup(label="Chatblocks", choices=[1,2,3,4,5,6,7,8,9,10])
131
  height=gr.Number(label="Height", value=4096)
132
  width=gr.Number(label="Width",value=800)
133
  message=gr.HTML('<center>Enter URL')
 
136
  outgal=gr.Gallery()
137
  outim = gr.Image()
138
 
139
+ btn.click(run_script,[inp,height,width,check_b],[outim,message,outgal])
140
  app.launch()