aliceblue11 commited on
Commit
bf00196
·
verified ·
1 Parent(s): 19d084b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import requests
2
  from bs4 import BeautifulSoup
3
  import gradio as gr
 
4
  import time
5
 
6
  def convert_to_mobile_url(url):
@@ -29,8 +30,9 @@ def scrape_naver_blog(url):
29
  "Referer": "https://www.naver.com/", # 네이버 메인 페이지를 참조 페이지로 설정
30
  }
31
 
32
- # 요청 전 3초 지연
33
- time.sleep(3)
 
34
 
35
  # URL로 GET 요청 보내기
36
  response = requests.get(url, headers=headers)
@@ -65,7 +67,7 @@ iface = gr.Interface(
65
  title="네이버 블로그 스크래퍼 (텍스트만)",
66
  description=(
67
  "네이버 블로그 URL(표준 또는 모바일)을 입력하면 제목과 텍스트 내용을 스크래핑합니다. "
68
- "스크립트는 표준 URL을 자동으로 모바일 형식으로 변환하며, 헤더와 3초 지연을 설정하여 요청을 자연스럽게 만듭니다."
69
  ),
70
  theme="compact", # 간결한 Gradio 인터페이스 테마
71
  )
 
1
  import requests
2
  from bs4 import BeautifulSoup
3
  import gradio as gr
4
+ import random
5
  import time
6
 
7
  def convert_to_mobile_url(url):
 
30
  "Referer": "https://www.naver.com/", # 네이버 메인 페이지를 참조 페이지로 설정
31
  }
32
 
33
+ # 요청 전 5~8초 지연
34
+ delay = random.uniform(5, 8)
35
+ time.sleep(delay)
36
 
37
  # URL로 GET 요청 보내기
38
  response = requests.get(url, headers=headers)
 
67
  title="네이버 블로그 스크래퍼 (텍스트만)",
68
  description=(
69
  "네이버 블로그 URL(표준 또는 모바일)을 입력하면 제목과 텍스트 내용을 스크래핑합니다. "
70
+ "스크립트는 표준 URL을 자동으로 모바일 형식으로 변환하며, 헤더와 5~8초 지연을 설정하여 요청을 자연스럽게 만듭니다."
71
  ),
72
  theme="compact", # 간결한 Gradio 인터페이스 테마
73
  )