Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,29 @@ import requests
|
|
2 |
from bs4 import BeautifulSoup
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def scrape_naver_blog(url):
|
6 |
try:
|
7 |
# Debugging: URL ํ์ธ
|
8 |
-
print(f"
|
9 |
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
-
response = requests.get(
|
14 |
response.raise_for_status()
|
15 |
|
16 |
# Debugging: HTTP ์๋ต ์ํ ํ์ธ
|
@@ -46,10 +60,10 @@ def run_scraper(url):
|
|
46 |
|
47 |
interface = gr.Interface(
|
48 |
fn=run_scraper,
|
49 |
-
inputs=gr.Textbox(label="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ URL
|
50 |
outputs=gr.Textbox(label="์คํฌ๋ํ ๊ฒฐ๊ณผ"),
|
51 |
title="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ์คํฌ๋ํ",
|
52 |
-
description="
|
53 |
)
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
2 |
from bs4 import BeautifulSoup
|
3 |
import gradio as gr
|
4 |
|
5 |
+
def convert_to_mobile_url(url):
|
6 |
+
"""
|
7 |
+
์
๋ ฅ๋ URL์ ๋ชจ๋ฐ์ผ URL๋ก ๋ณํ.
|
8 |
+
"""
|
9 |
+
if "m.blog.naver.com" not in url:
|
10 |
+
if "blog.naver.com" in url:
|
11 |
+
url_parts = url.split("/")
|
12 |
+
if len(url_parts) >= 5:
|
13 |
+
user_id = url_parts[3]
|
14 |
+
post_id = url_parts[4]
|
15 |
+
return f"https://m.blog.naver.com/{user_id}/{post_id}"
|
16 |
+
return url
|
17 |
+
|
18 |
def scrape_naver_blog(url):
|
19 |
try:
|
20 |
# Debugging: URL ํ์ธ
|
21 |
+
print(f"Original URL: {url}")
|
22 |
|
23 |
+
# ๋ชจ๋ฐ์ผ URL๋ก ๋ณํ
|
24 |
+
mobile_url = convert_to_mobile_url(url)
|
25 |
+
print(f"Converted Mobile URL: {mobile_url}")
|
26 |
|
27 |
+
response = requests.get(mobile_url)
|
28 |
response.raise_for_status()
|
29 |
|
30 |
# Debugging: HTTP ์๋ต ์ํ ํ์ธ
|
|
|
60 |
|
61 |
interface = gr.Interface(
|
62 |
fn=run_scraper,
|
63 |
+
inputs=gr.Textbox(label="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ URL"),
|
64 |
outputs=gr.Textbox(label="์คํฌ๋ํ ๊ฒฐ๊ณผ"),
|
65 |
title="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ์คํฌ๋ํ",
|
66 |
+
description="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ URL์ ์
๋ ฅํ๋ฉด ๋ชจ๋ฐ์ผ URL๋ก ๋ณํ ํ ์ ๋ชฉ๊ณผ ํ
์คํธ ๋ด์ฉ์ ์คํฌ๋ํํฉ๋๋ค."
|
67 |
)
|
68 |
|
69 |
if __name__ == "__main__":
|