S&P 500 μ§μμ κ΄λ ¨ λ°μ΄ν° μ€μκ°μΌλ‘ μΆμΆνκΈ°
μ΄λ² μμ
μμλ Yahoo Financeμμ S&P 500
μ£Όμ λ°μ΄ν°λ₯Ό μΆμΆνλ λ°©λ²μ μμλ³΄κ² μ΅λλ€.
1. νμ¬κ° κ°μ Έμ€κΈ°
current_price_element = driver.find_element(By.XPATH, "//div[contains(@class, 'price')]//fin-streamer[contains(@class, 'livePrice')]//span") current_price = current_price_element.text
find_element()
λ νμ΄μ§μμ νΉμ μμλ₯Ό μ°Ύμ΅λλ€.
XPATHλ‘ μ μλ λ΄μ©μ λ€μκ³Ό κ°μ΅λλ€.
-
div[contains(@class, 'price')] :
div
νκ·Έ μ€price
ν΄λμ€λ₯Ό ν¬ν¨νλ μμ -
fin-streamer[contains(@class, 'livePrice')] :
fin-streamer
νκ·Έ μ€livePrice
ν΄λμ€λ₯Ό ν¬ν¨νλ μμ -
span :
span
νκ·Έ
μ¦ XPATHλ div
νκ·Έ μ€ price
ν΄λμ€λ₯Ό ν¬ν¨νκ³ , fin-streamer
νκ·Έ μ€ livePrice
ν΄λμ€λ₯Ό ν¬ν¨νλ©°, span
νκ·ΈμΈ μμλ₯Ό μ νν©λλ€.
2. Previous Close κ° κ°μ Έμ€κΈ°
previous_close_element = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'fin-streamer[data-field="regularMarketPreviousClose"]'))) previous_close = previous_close_element.text
By.CSS_SELECTOR
λ CSS μ νμλ₯Ό μ¬μ©νμ¬ data-field="regularMarketPreviousClose"
μμ±μ κ°μ§ fin-streamer
νκ·Έλ₯Ό μ νν©λλ€.
XPATHλ‘ μ μλ λ΄μ©μ λ€μκ³Ό κ°μ΅λλ€.
- fin-streamer[data-field="regularMarketPreviousClose"] :
fin-streamer
νκ·Έ μ€data-field="regularMarketPreviousClose"
μμ±μ κ°μ§ μμ
previous_close_elementμλ Previous Close κ°μ κ°μ§ μμκ° μ μ₯λ©λλ€.
previous_close_element.text
λ Previous Close κ°μ ν
μ€νΈλ‘ κ°μ Έμ΅λλ€.
3. Volume κ° κ°μ Έμ€κΈ°
volume_element = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'fin-streamer[data-field="regularMarketVolume"]'))) volume = volume_element.text
data-field="regularMarketVolume"
μμ±μ κ°μ§ fin-streamer
νκ·Έλ₯Ό μ ννμ¬ Volume κ°μ κ°μ Έμ΅λλ€.
volume_element.text
λ Volume κ°μ ν
μ€νΈλ‘ κ°μ Έμ΅λλ€.
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Execution Result