ckfrpark commited on
Commit
5b573f3
β€’
1 Parent(s): 2375b0d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+
5
+ def scrape_website(url):
6
+ # μ›Ή νŽ˜μ΄μ§€μ˜ λ‚΄μš©μ„ κ°€μ Έμ˜΅λ‹ˆλ‹€.
7
+ response = requests.get(url)
8
+ # BeautifulSoup 객체λ₯Ό μƒμ„±ν•˜μ—¬ HTML을 νŒŒμ‹±ν•©λ‹ˆλ‹€.
9
+ soup = BeautifulSoup(response.text, 'html.parser')
10
+ # μ›Ή νŽ˜μ΄μ§€μ˜ 타이틀을 μΆ”μΆœν•©λ‹ˆλ‹€.
11
+ title = soup.find('title').text
12
+ return title
13
+
14
+ with gr.Blocks() as demo:
15
+ gr.Markdown("### μ›Ή μŠ€ν¬λž˜ν•‘ ν”„λ‘œκ·Έλž¨")
16
+ url_input = gr.Textbox(label="URL을 μž…λ ₯ν•˜μ„Έμš”")
17
+ output = gr.Textbox(label="μ›Ή νŽ˜μ΄μ§€ 타이틀")
18
+ gr.Button("슀크랩").click(scrape_website, inputs=url_input, outputs=output)
19
+
20
+ if __name__ == "__main__":
21
+ demo.launch()