import requests from bs4 import BeautifulSoup import get_url url = get_url.fetch_data_from_mariadb()['url'] def getContents(): # HTTP GET 요청으로 페이지 가져오기 response = requests.get(url) # 응답 상태 확인 if response.status_code == 200: # HTML 파싱 soup = BeautifulSoup(response.text, 'html.parser') # HTML 태그를 제거 후 페이지의 모든 텍스트 가져오기 (전체 내용) page_content = soup.get_text() # 빈 줄을 제거하고 텍스트만 출력 (줄바꿈 문자를 기준으로 필터링) lines = [line.strip() for line in page_content.splitlines() if line.strip()] # 결과 출력 contents = "\n".join(lines) return contents else: print(f"Failed to fetch the URL. Status code: {response.status_code}") tmp = getContents() print(tmp)