행위

미국 주가 지수

DB CAFE

thumb_up 추천메뉴 바로가기


파이썬 게더링

https://financedata.github.io/posts/finance-data-reader-users-guide.html

나스닥 선물[편집]

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time

browser = webdriver.Edge()
browser.get("https://kr.investing.com/indices/nq-100-futures")

time_save = ""
while True:
    try:
        element = browser.find_element_by_xpath("//div[@class='inlineblock']")
        if element:
            inner_text = element.text.splitlines()
            nqf_str = inner_text[0].split(' ')
            stat_str = inner_text[1].split('-')
            cur_time = stat_str[0].rstrip()
            cur_stat = stat_str[1].split('.')[0].strip()
            if cur_time != time_save:
                print(cur_time, nqf_str[0], nqf_str[1], nqf_str[-1], cur_stat)
                time_save = cur_time
    except Exception as ex:
        print("Unhandled exception:", ex)
        break
    time.sleep(1)