당신의 친절한 이웃, 코딩맨

#25 Python - beautifulSoup으로 코스피 정보를 불러오는 웹 크롤링 본문

Today I Learn (TIL)

#25 Python - beautifulSoup으로 코스피 정보를 불러오는 웹 크롤링

이웃집 친구 2020. 7. 17. 14:22
반응형

# 1. 필요한 모듈을 불러오세요.
import requests
from bs4 import BeautifulSoup
# 2. requests 모듈로 요청을 보내세요.
url = 'https://finance.naver.com/sise/'
# 3. bs4 모듈로 데이터를 가져오세요.
response = requests.get(url).text

data = BeautifulSoup(response, 'html.parser')
result = data.select_one('#KOSPI_now')

print(result.text)
Comments