Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,20 +23,25 @@ def gradio_fetch_and_parse(url):
|
|
23 |
|
24 |
def get_main_content(html_content):
|
25 |
soup = BeautifulSoup(html_content, 'html.parser')
|
26 |
-
# ์: ๋ณธ๋ฌธ ๋ด์ฉ์ด <div class="main-content"> ์์ ์๋ค๊ณ ๊ฐ์
|
27 |
main_content = soup.find('div', class_='main-content')
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
def format_script(text):
|
31 |
-
# ํ
์คํธ๋ฅผ ๋ฌธ์ฅ๋ณ๋ก ๋ถ๋ฆฌ
|
32 |
sentences = text.split('.')
|
33 |
-
# 2๋ฌธ์ฅ์ฉ ๋ฌถ์ด์ ์คํฌ๋ฆฝํธ ํํ๋ก ์์ฑ
|
34 |
script = ""
|
35 |
for i in range(0, min(len(sentences), 10), 2):
|
36 |
-
|
37 |
if i+1 < len(sentences):
|
38 |
-
|
|
|
|
|
39 |
return script
|
|
|
40 |
|
41 |
# Gradio ์ธํฐํ์ด์ค ํจ์
|
42 |
def gradio_fetch_and_format_script(url):
|
|
|
23 |
|
24 |
def get_main_content(html_content):
|
25 |
soup = BeautifulSoup(html_content, 'html.parser')
|
|
|
26 |
main_content = soup.find('div', class_='main-content')
|
27 |
+
if main_content:
|
28 |
+
text = main_content.get_text(strip=True)
|
29 |
+
print("์ถ์ถ๋ ํ
์คํธ:", text) # ๋๋ฒ๊น
์ ์ํ ๋ก๊ทธ
|
30 |
+
return text
|
31 |
+
else:
|
32 |
+
return ''
|
33 |
|
34 |
def format_script(text):
|
|
|
35 |
sentences = text.split('.')
|
|
|
36 |
script = ""
|
37 |
for i in range(0, min(len(sentences), 10), 2):
|
38 |
+
line = sentences[i].strip() + '. '
|
39 |
if i+1 < len(sentences):
|
40 |
+
line += sentences[i+1].strip() + '\n'
|
41 |
+
script += line
|
42 |
+
print("ํ์ฌ ์คํฌ๋ฆฝํธ:", script) # ๋๋ฒ๊น
์ ์ํ ๋ก๊ทธ
|
43 |
return script
|
44 |
+
|
45 |
|
46 |
# Gradio ์ธํฐํ์ด์ค ํจ์
|
47 |
def gradio_fetch_and_format_script(url):
|