-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (55 loc) · 1.88 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from multiprocessing import Pool
from pytz import timezone
import DataCrawling
import csv
import datetime
import schedule
import time
def createCrawler(account_num):
path = "./data/output/"
dataCrawler = DataCrawling.MarketHandler(account_num)
dataCrawler.get_price_data()
if account_num == 0:
with open(path + "Material_data.csv", 'w', newline='') as file:
writer = csv.writer(file)
for row in dataCrawler.price_data_list:
writer.writerow(row)
file.close()
else:
with open(path + "Engrave_data.csv", 'w', newline='') as file:
writer = csv.writer(file)
for row in dataCrawler.price_data_list:
writer.writerow(row)
file.close()
def csv_integration():
path = "./data/output/"
with open(path + "Material_data.csv", 'r', encoding='utf-8') as file:
reader = csv.reader(file)
material_data = list(reader)
file.close()
with open(path + "Engrave_data.csv", 'r', encoding='utf-8') as file:
reader = csv.reader(file)
for line in reader:
material_data.append(line)
file.close()
with open(path + "Total_data.csv", 'w', newline='') as file:
writer = csv.writer(file)
for row in material_data:
writer.writerow(row)
file.close()
print("integration complete")
def start_process():
process_pool = Pool(2)
process_pool.map_async(createCrawler, [0, 1])
process_pool.close()
process_pool.join()
def chk_time():
chk_time = datetime.datetime.now(timezone('Asia/Seoul'))
if (chk_time.minute == 20 and chk_time.second == 0) or (chk_time.minute == 50 and chk_time.second == 0):
start_process()
csv_integration()
if __name__ == '__main__':
schedule.every(1).seconds.do(chk_time)
while True:
schedule.run_pending()
time.sleep(1)