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()
|