728x90
반응형
메뉴 접근법
야후 finance -> 아래로 스크롤하다보면 오른쪽에 Stocks: Most Actives 나옴. -> 클릭
위 화면에서 클릭을 하게 되면...아래와 같은 화면이 나옴....여기에 있는 내용중에 Symbol, Price, Change 를 가져오기
소스코드
from bs4 import BeautifulSoup as BS
import requests as req
url = "https://finance.yahoo.com/most-active"
res = req.get(url)
soup = BS(res.text, "html.parser")
for tr in soup.select("table tbody tr"):
#price = tr.select("td.colspan:nth-child(4)")[0].get_text(strip=True)
title = tr.select("td:nth-child(1) a")[0].get_text(strip=True)
price = tr.select("td:nth-child(3) fin-streamer")[0].get_text(strip=True)
change = tr.select("td:nth-child(4) fin-streamer")[0].get_text(strip=True)
print(title, price, change)
728x90
반응형
'BIG DATA > 크롤링' 카테고리의 다른 글
XHR 통신 (0) | 2021.10.01 |
---|---|
네이버 주식 검색상위 종목 크롤링 (0) | 2021.09.30 |
css 셀렉터 고급 한정자 (0) | 2021.09.27 |
css 셀렉터 퀴즈 (한정자) (0) | 2021.09.27 |
css 셀렉터 정규식 쓰는법 (0) | 2021.09.27 |
댓글