This commit is contained in:
dosangyoon
2021-11-13 11:55:38 +09:00
parent 72828f3d39
commit a6e8b738e1
2 changed files with 13 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import json
import sqlite3
import requests
import math
import time
class Queue(object):
def __init__(self, max):
@@ -145,13 +146,14 @@ class StockCrawler:
stocks.append({"NAME": 'KODEX 은행', "CODE": "091170", "PRICE": []})
stocks.append({"NAME": 'TIGER 탄소효율그린뉴딜', "CODE": "376410", "PRICE": []})
start_time = time.time()
for i, stock in enumerate(stocks):
print (i, stock["NAME"], stock["CODE"])
print (i, stock["NAME"], stock["CODE"], (time.time()-start_time), "s")
start_time = time.time()
cursor.execute('SELECT * FROM ' + tableName + ' WHERE CODE=?', (stock["CODE"],))
result = cursor.fetchone()
if result != None:
stock["PRICE"] = json.loads(result[2])
self.crawl_specific_stock(stock)
text = json.dumps(stock['PRICE'], ensure_ascii=False)
@@ -176,13 +178,15 @@ class StockCrawler:
code_df = self.getStockInfo()
items = code_df.values
start_time = time.time()
idx = 0
for item in items:
idx += 1
item_name = item[0]
item_code = item[1]
print(idx, item_name, item_code)
print(idx, item_name, item_code, (time.time()-start_time),"s")
start_time = time.time()
cursor.execute('SELECT * FROM ' + tableName + ' WHERE CODE=?', (item_code,))
result = cursor.fetchone()