추천로직
This commit is contained in:
30
backend/test_naver.py
Normal file
30
backend/test_naver.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
HEADERS = {"User-Agent": "Mozilla/5.0 (compatible; autostock-batch/1.0)"}
|
||||
|
||||
url = "https://finance.naver.com/sise/sise_market_sum.naver"
|
||||
resp = requests.get(url, params={"sosok": 0, "page": 1}, headers=HEADERS)
|
||||
print(f"상태코드: {resp.status_code}")
|
||||
|
||||
soup = BeautifulSoup(resp.content, "html.parser", from_encoding="euc-kr")
|
||||
|
||||
# 어떤 table 태그들이 있는지 확인
|
||||
tables = soup.find_all("table")
|
||||
print(f"\ntable 개수: {len(tables)}")
|
||||
for i, t in enumerate(tables[:5]):
|
||||
print(f" table[{i}] class={t.get('class')}")
|
||||
|
||||
# type_2 테이블 직접 찾기
|
||||
t2 = soup.find("table", {"class": "type_2"})
|
||||
print(f"\ntype_2 테이블 존재: {t2 is not None}")
|
||||
|
||||
if t2:
|
||||
rows = t2.find_all("tr")
|
||||
print(f"tr 개수: {len(rows)}")
|
||||
for row in rows[:5]:
|
||||
print(f" row: {str(row)[:200]}")
|
||||
else:
|
||||
# HTML 앞부분 출력
|
||||
print("\nHTML 앞 2000자:")
|
||||
print(resp.text[:2000])
|
||||
Reference in New Issue
Block a user