Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ def scrape_naver_blog(url):
|
|
20 |
try:
|
21 |
# Convert URL to mobile format if necessary
|
22 |
url = convert_to_mobile_url(url)
|
23 |
-
|
24 |
# HTTP request headers
|
25 |
headers = {
|
26 |
"User-Agent": (
|
@@ -29,9 +29,10 @@ def scrape_naver_blog(url):
|
|
29 |
),
|
30 |
"Referer": "https://www.naver.com/",
|
31 |
}
|
32 |
-
|
33 |
# Random delay between 1 to 3 seconds
|
34 |
-
|
|
|
35 |
|
36 |
# Send a GET request to the URL
|
37 |
response = requests.get(url, headers=headers)
|
@@ -64,9 +65,9 @@ iface = gr.Interface(
|
|
64 |
title="네이버 블로그 스크래퍼 (텍스트만)",
|
65 |
description=(
|
66 |
"네이버 블로그 URL(표준 또는 모바일)을 입력하면 제목과 텍스트 내용을 스크래핑합니다. "
|
67 |
-
"스크립트는 표준 URL을 자동으로 모바일 형식으로
|
68 |
),
|
69 |
-
theme="compact", # Gradio
|
70 |
)
|
71 |
|
72 |
if __name__ == "__main__":
|
|
|
20 |
try:
|
21 |
# Convert URL to mobile format if necessary
|
22 |
url = convert_to_mobile_url(url)
|
23 |
+
|
24 |
# HTTP request headers
|
25 |
headers = {
|
26 |
"User-Agent": (
|
|
|
29 |
),
|
30 |
"Referer": "https://www.naver.com/",
|
31 |
}
|
32 |
+
|
33 |
# Random delay between 1 to 3 seconds
|
34 |
+
delay = random.uniform(1, 3)
|
35 |
+
time.sleep(delay)
|
36 |
|
37 |
# Send a GET request to the URL
|
38 |
response = requests.get(url, headers=headers)
|
|
|
65 |
title="네이버 블로그 스크래퍼 (텍스트만)",
|
66 |
description=(
|
67 |
"네이버 블로그 URL(표준 또는 모바일)을 입력하면 제목과 텍스트 내용을 스크래핑합니다. "
|
68 |
+
"스크립트는 표준 URL을 자동으로 모바일 형식으로 변환하며, 헤더와 랜덤 딜레이를 설정하여 요청을 자연스럽게 만듭니다."
|
69 |
),
|
70 |
+
theme="compact", # 간결한 Gradio 인터페이스 테마
|
71 |
)
|
72 |
|
73 |
if __name__ == "__main__":
|