연습용으로만 해보시길...
import requests
from bs4 import BeautifulSoup
url = 'https://finance.naver.com/item/main.nhn?code=005930'
res = requests.get(url)
soup = BeautifulSoup(res.content, 'html.parser')
# <span class="no5">5</span>
div_today = soup.find('div', {'class': 'today'})
# print(div_today)
td_today = div_today.find('span', {'class': 'blind'})
# print(td_today)
print('종가',td_today.text)
td_firsts = soup.findAll('td', {'class': 'first'})
for td_first in td_firsts:
# print(td_first)
# print('----------------')
# print(td_first.find('span', {'class': 'blind'}))
print(td_first.find('span', {'class': 'blind'}).text)
'크롤링' 카테고리의 다른 글
로또 번호 추출 코드 예제 (0) | 2020.10.06 |
---|---|
colab에서 selenium 사용하는 법 (0) | 2020.10.05 |
네이버에서 고양이 이미지 가져오기 코드 (0) | 2020.10.05 |
울산 코로나 환자 현황 크롤링 (0) | 2020.09.29 |
크롤링 (Crawling) (0) | 2020.09.28 |