File size: 956 Bytes
e0b4e38
de01cb6
 
 
 
4d75a6f
de01cb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f150bb6
de01cb6
 
 
 
 
 
 
 
f150bb6
de01cb6
 
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
35
36
37
import gradio as gr
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

def scrape_website(url):
    # Create a new instance of the Chrome driver
    driver = webdriver.Chrome()
    
    # Navigate to the provided URL
    driver.get(url)
    
    # Wait until all processes are complete
    wait = WebDriverWait(driver, 10)  # Maximum wait time in seconds
    wait.until(EC.presence_of_element_located((By.TAG_NAME, 'body')))
    
    # Extract the page title
    title = driver.title
    
    # Close the browser
    driver.quit()
    
    return title

# Define the Gradio interface
interface = gr.Interface(
    fn=scrape_website,
    inputs="text",
    outputs="text",
    title="Web Scraping Application",
    description="Enter a URL to extract the page title."
)

# Run the Gradio app
interface.launch()