-
-
Save jaecheol-jeong/557000a7c85df168f0d34845946f1f9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 다음 금융 일봉 크롤링 | |
import requests | |
from bs4 import BeautifulSoup | |
import json | |
url = 'https://finance.daum.net/api/charts/A066570/days?limit=200&adjusted=true' | |
headers = { | |
"referer": "https://finance.daum.net/chart/A005930", | |
"user-agent": "Mozilla/5.0" | |
} | |
params = { | |
"limit": "200", | |
"adjusted": "true" | |
} | |
r = requests.get(url, headers=headers, params=params) | |
szContent = r.text | |
print (szContent) | |
#soup = BeautifulSoup(html, 'html.parser') | |
#titles = soup.select('span') | |
str_list = [] | |
list = json.loads(szContent) | |
for price in list["data"]: | |
str_list.append(price["symbolCode"]) | |
str_list.append(" ") | |
str_list.append(price["date"]) | |
str_list.append(" : ") | |
str_list.append(str(price["tradePrice"]).replace(".0", "")) | |
str_list.append(" 원\n") | |
print("".join(str(v) for v in str_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment