app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,14 @@ def extract(url):
|
|
| 7 |
try:
|
| 8 |
r = requests.get(url, headers=headers, timeout=10)
|
| 9 |
r.raise_for_status()
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
return text or "๋ณธ๋ฌธ์ ์ถ์ถํ ์ ์์ต๋๋ค."
|
| 12 |
except requests.exceptions.Timeout:
|
| 13 |
return "์์ฒญ์ด ์๊ฐ ์ด๊ณผ๋์์ต๋๋ค."
|
|
@@ -19,9 +26,9 @@ def extract(url):
|
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=extract,
|
| 21 |
inputs=gr.Textbox(label="URL ์
๋ ฅ", placeholder="https://example.com"),
|
| 22 |
-
outputs=gr.Textbox(label="์ถ์ถ๋ ๋ณธ๋ฌธ", lines=
|
| 23 |
title="๋ณธ๋ฌธ ์ถ์ถ๊ธฐ",
|
| 24 |
-
description="์นํ์ด์ง URL์ ์
๋ ฅํ๋ฉด
|
| 25 |
)
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
|
|
|
| 7 |
try:
|
| 8 |
r = requests.get(url, headers=headers, timeout=10)
|
| 9 |
r.raise_for_status()
|
| 10 |
+
# full_text=True โ ๊ฐ๋ฅํ ๋ชจ๋ ํ
์คํธ ์ถ์ถ
|
| 11 |
+
text = trafilatura.extract(
|
| 12 |
+
r.text,
|
| 13 |
+
include_comments=False,
|
| 14 |
+
include_tables=True,
|
| 15 |
+
no_fallback=False,
|
| 16 |
+
favor_recall=True
|
| 17 |
+
)
|
| 18 |
return text or "๋ณธ๋ฌธ์ ์ถ์ถํ ์ ์์ต๋๋ค."
|
| 19 |
except requests.exceptions.Timeout:
|
| 20 |
return "์์ฒญ์ด ์๊ฐ ์ด๊ณผ๋์์ต๋๋ค."
|
|
|
|
| 26 |
iface = gr.Interface(
|
| 27 |
fn=extract,
|
| 28 |
inputs=gr.Textbox(label="URL ์
๋ ฅ", placeholder="https://example.com"),
|
| 29 |
+
outputs=gr.Textbox(label="์ถ์ถ๋ ๋ณธ๋ฌธ", lines=30),
|
| 30 |
title="๋ณธ๋ฌธ ์ถ์ถ๊ธฐ",
|
| 31 |
+
description="์นํ์ด์ง URL์ ์
๋ ฅํ๋ฉด ๊ฐ๋ฅํ ๋ง์ ๋ณธ๋ฌธ์ ์ถ์ถํฉ๋๋ค."
|
| 32 |
)
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|