Create app.py
Browse files
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()
|