-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.py
81 lines (72 loc) · 2.72 KB
/
run.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
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
# first initialization : source hamu/bin/active
from lib.util.get_code import *
from lib.get_price import *
from lib.get_real_price import *
from lib.util.logger import *
import time
import argparse
now = time.localtime()
YEAR = now.tm_year
# initialized logger
area_code = '4113510700' # 야탑동 (법정동 코드 https://goo.gl/P6ni8Q 참조)
apt_name = '매화마을공무원2단지' # 장미8단지현대, 탑벽산
min_date = '19.10.01'
AREA_CODE_TABLE = {
6334: '장미마을 현대',
6315: '매화마을 2단지',
6339: '야탑 벽산',
6360: '청라한솔',
50369: '정자 정든마을'
}
FLAGS = None
def initialization():
init_logger()
return logging.getLogger("logger")
def run():
arg = input(f"1. 네이버 호가 검색 => naver \n2. 실거래가 => real \n3. 실거래가 모두 => real-all\n입력해주세요: ")
if arg == 'naver':
get_naver_realasset(area_code, apt_name, min_date)
elif arg == 'real':
f = open(f"{YEAR}-realprice.md", "a")
target = int(input(f"6334: '장미마을' \n6315: '매화 2단지' \n6339: '벽산' \n6360: '청라한솔' \n50369: '정자 정든마을' \n: "))
result = get_detail_real_price(target, YEAR)
print(result, file=f)
f.close()
elif arg == 'real-all':
f = open(f"{YEAR}-real-price-all.md", "w")
result = "# 실거래가 모음\n" + "Updated Date: " + str(now.tm_mon) + "월" + str(now.tm_mday) + "일\n"
for key in AREA_CODE_TABLE.keys():
result += get_detail_real_price(key, YEAR)
print(result, file=f)
f.close()
else:
logger("input 값이 이상함")
def main():
logger = initialization()
parser = argparse.ArgumentParser()
parser.add_argument('--dev', type=str, default='false', help='if this is true, only using real-all')
FLAGS = parser.parse_args()
if FLAGS.dev == 'true':
f = open(f"{YEAR}-real-price-all.md", "w")
result = "# 실거래가 모음\n" + "Updated Date: " + str(now.tm_mon) + "월" + str(now.tm_mday) + "일\n"
for key in AREA_CODE_TABLE.keys():
result += get_detail_real_price(key, YEAR)
print(result, file=f)
f.close()
else:
run()
main()
# df = pd.DataFrame()
# for i in range(1, 50): # 최대 100 페이지
# df_tmp = get_naver_realasset(area_code, apt_name, min_date,i)
# if len(df_tmp) <= 0:
# break
# df = df.append(df_tmp, ignore_index=True)
# 6334 장미마을, 6315 매화마을 2단지, 6339 벽산, 6360 청라한솔, 50369 정자 정든마을
# get_detail_real_price(6315, 2019)
# get_detail_real_price(50369, 2019)
# get_avg_real_price(6334, 2019)
# p = '경기도 성남시 분당구 야탑동'
# df_province = get_province(p)
# value = df_province.loc[df_province['법정동명'] == p, '법정동코드'].values[0]