ckfrpark commited on
Commit
5b573f3
ยท
verified ยท
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()