행위

"미국 주가 지수"의 두 판 사이의 차이

DB CAFE

 
3번째 줄: 3번째 줄:
 
https://financedata.github.io/posts/finance-data-reader-users-guide.html
 
https://financedata.github.io/posts/finance-data-reader-users-guide.html
  
 +
== 나스닥 선물 ==
 +
<source lang=python>
 +
 +
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)
 +
 +
</source>
  
 
[[category:주식]]
 
[[category:주식]]

2020년 6월 18일 (목) 06:23 기준 최신판

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)