-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
추가 질문드립니다.
22.04.09 20:49 작성 조회수 116
1
import requests
from bs4 import BeautifulSoup
import openpyxl
fpath = r"C:\Users\OWNER\Desktop\python\주식.xlsx"
wb = openpyxl.load_workbook(fpath)
ws = wb.active
codes = [
'005930',
'000660',
'035720'
]
row = 2
for code in codes :
url = f"https://finance.naver.com/item/sise.naver?code={codes}"
response = requests.get(url)
html = response.text
soup = BeautifulSoup(html,'html.parser')
price = soup.select_one('#_nowVal').text
price = price.replace(',', '')
print(price)
wb.save(fpath)
값이 빈어서 출력이 됩니다...
답변을 작성해보세요.
0
답변 1