mgokg commited on
Commit
c5306b6
·
verified ·
1 Parent(s): f542379

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -16
app.py CHANGED
@@ -11,26 +11,16 @@ def take_screenshot(url):
11
  options.add_argument('--headless')
12
  options.add_argument('--no-sandbox')
13
  options.add_argument('--disable-dev-shm-usage')
 
 
 
 
 
14
 
15
- try:
16
- wd = webdriver.Chrome(options=options)
17
- wd.set_window_size(1080, 720) # Adjust the window size here
18
- wd.get(url)
19
- wd.implicitly_wait(5)
20
- resp=driver.find_element(By.TAG_NAME, "a")
21
- return resp
22
- #screenshot = wd.get_screenshot_as_png()
23
- except WebDriverException as e:
24
- return resp
25
- finally:
26
- if wd:
27
- wd.quit()
28
-
29
- return Image.open(BytesIO(screenshot))
30
 
31
  iface = gr.Interface(
32
  fn=take_screenshot,
33
- inputs=gr.Textbox(label="Website URL", value="https://kargaranamir.github.io"),
34
  outputs=gr.Textbox(),
35
  title="Website Screenshot",
36
  description="Take a screenshot of a website."
 
11
  options.add_argument('--headless')
12
  options.add_argument('--no-sandbox')
13
  options.add_argument('--disable-dev-shm-usage')
14
+ wd = webdriver.Chrome(options=options)
15
+ wd.get(url)
16
+ wd.implicitly_wait(10)
17
+ resp=driver.find_element(By.TAG_NAME, "a")
18
+ return resp
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  iface = gr.Interface(
22
  fn=take_screenshot,
23
+ inputs=gr.Textbox(label="Website URL", value="https://spiegel.de"),
24
  outputs=gr.Textbox(),
25
  title="Website Screenshot",
26
  description="Take a screenshot of a website."