반응형
[5] 이마트(E-Mart) 매장 조회 크롤링 [무작정 따라하기 3]

Emart 매장조회 크롤링 소스를 복사하여 사용하세요.
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
import requests
import datetime
print('──────────────────────────────────────────────────')
print('★★★★★★★★EMART 매장조회 프로그램★★★★★★★★')
print('──────────────────────────────────────────────────')
while True:
targetSite1 = 'https://store.emart.com/main/area/list.do' # 매장 조회에 필요한 시/도 정보를 요청하는 경로
request = requests.post(targetSite1) # 해당 경로를 호출하여 정보를 요청
sido_list = request.json() # 전달받은 json 값을 List에 저장
print('00 : 전체')
for sido in sido_list['areaList']:
print(sido['code'] + ' : ' + sido['name'])
sido_cd = input('시/도 코드를 입력해주세요 : ')
dt_datetime = datetime.datetime.now() # 현재의 날짜, 시간 정보
fformat = "%Y%m%d%H%M%S" # 년,월,일,시,분,초
y_date = "%Y" # 현재의 년도
m_date = "%m" # 현재의 월
str_today = datetime.datetime.strftime(dt_datetime, fformat)
y_today = datetime.datetime.strftime(dt_datetime, y_date)
m_today = datetime.datetime.strftime(dt_datetime, m_date)
targetSite2 = 'https://store.emart.com/branch/searchList.do'
request = requests.post(targetSite2, data={
'srchMode': 'jujum',
'areaId': sido_cd,
'sHanSort': '',
'eHanSort': '',
'year': y_today,
'month': m_today,
'jMode': 'true',
'strConfirmYN': 'N',
'strName': '',
'strName1': '',
'strName2': '',
})
emart_list = request.json()
emartList = {}
# ##print(emart_list)## : 리스트 print를 통해서 아래와 같이 json parameter들을 확인할 수 있습니다.
f = open('emart_' + str_today + '.txt', 'w')
f.write('순번' + '\t' + '지점명' + '\t' + '도로명주소' + '\t' + '위도/경도' + '\n')
for emart in emart_list['dataList']:
# json parameter list
emartList['CULTURE_TEL'] = emart['CULTURE_TEL'] # 컬저클럽(문화센터) 전화번호
emartList['HOLIDAY_DAY2'] = emart['HOLIDAY_DAY2']
emartList['HOLIDAY_DAY1'] = emart['HOLIDAY_DAY1']
emartList['HOLIDAY_DAY3'] = emart['HOLIDAY_DAY3']
emartList['AREA_CODE'] = emart['AREA_CODE'] # 지역코드(초기 선택지와 동일)
emartList['RENEWAL_YN'] = emart['RENEWAL_YN']
emartList['STORE_E_YN'] = emart['STORE_E_YN']
emartList['MODIFY_DATE'] = emart['MODIFY_DATE']
emartList['ELECTRIC_YN'] = emart['ELECTRIC_YN'] # 일렉트마트 유무
emartList['STORE_M_YN'] = emart['STORE_M_YN']
emartList['STORE_FD_YN'] = emart['STORE_FD_YN']
emartList['ID'] = emart['ID'] # 매장 고유 ID
emartList['SPEC'] = emart['SPEC']
emartList['HOLIDAY_DAY1_YYYYMMDD'] = emart['HOLIDAY_DAY1_YYYYMMDD']
emartList['STORE_DL_YN'] = emart['STORE_DL_YN']
emartList['HOLIDAY_DAY3_DAY'] = emart['HOLIDAY_DAY3_DAY']
emartList['FLOOR_START'] = emart['FLOOR_START']
emartList['HOLIDAY_DAY2_DAY'] = emart['HOLIDAY_DAY2_DAY']
emartList['MODIFY_ADMIN_ID'] = emart['MODIFY_ADMIN_ID']
emartList['HOLIDAY_DAY3_YYYYMMDD'] = emart['HOLIDAY_DAY3_YYYYMMDD']
emartList['COM_CODE'] = emart['COM_CODE']
emartList['STORE_SHOPPING_TIME'] = emart['STORE_SHOPPING_TIME'] # 매장운영시간
emartList['STORE_TK_YN'] = emart['STORE_TK_YN']
emartList['PARKING_COUNT'] = emart['PARKING_COUNT'] # 주차대수
emartList['OIL_YN'] = emart['OIL_YN']
emartList['DISPLAY_YN'] = emart['DISPLAY_YN']
emartList['STORE_SS_YN'] = emart['STORE_SS_YN']
emartList['BOOKMARK_YN'] = emart['BOOKMARK_YN']
emartList['STORE_TP'] = emart['STORE_TP']
emartList['STORE_L_YN'] = emart['STORE_L_YN']
emartList['HOLIDAY_DAY1_DAY'] = emart['HOLIDAY_DAY1_DAY']
emartList['STORE_P_YN'] = emart['STORE_P_YN']
emartList['START_DAY'] = emart['START_DAY']
emartList['STORE_SC_YN'] = emart['STORE_SC_YN']
emartList['STORE_BC_YN'] = emart['STORE_BC_YN']
emartList['REGIST_ADMIN_ID'] = emart['REGIST_ADMIN_ID']
emartList['MAP_INFO'] = emart['MAP_INFO'] # 대중교통정보
emartList['HOLIDAY_DAY2_YYYYMMDD'] = emart['HOLIDAY_DAY2_YYYYMMDD']
emartList['STORE_DC_YN'] = emart['STORE_DC_YN']
emartList['CLOSE_SHOPPING_TIME'] = emart['CLOSE_SHOPPING_TIME'] # 매장마감시간
emartList['STORE_BT_YN'] = emart['STORE_BT_YN']
emartList['ADDRESS1'] = emart['ADDRESS1'] # 도로명주소
emartList['OPEN_SHOPPING_TIME'] = emart['OPEN_SHOPPING_TIME'] # 매장오픈시간
emartList['ADDRESS3'] = emart['ADDRESS3'] # 지번주소
emartList['ADDRESS2'] = emart['ADDRESS2'] # 상세주소
emartList['JIJUM_STATUS'] = emart['JIJUM_STATUS'] # 지점오픈여부
emartList['INTRO'] = emart['INTRO'] # oracle DB 정보
emartList['ZIPCODE'] = emart['ZIPCODE'] # 우편번호
emartList['STORE_PK_YN'] = emart['STORE_PK_YN']
emartList['START_MONTH'] = emart['START_MONTH']
emartList['CULTURE_ID'] = emart['CULTURE_ID']
emartList['START_YEAR'] = emart['START_YEAR']
emartList['FLOOR_END'] = emart['FLOOR_END']
emartList['STORE_N_YN'] = emart['STORE_N_YN']
emartList['TEL'] = emart['TEL'] # 매장전화번호
emartList['NO'] = emart['RNUM'] # 출력순번
emartList['NAME'] = emart['NAME'] # 매장명
emartList['ADDRESS'] = emart['ADDRESS1'] # 도로명주소
emartList['MAP_X'] = emart['MAP_X'] # 위도
emartList['MAP_Y'] = emart['MAP_Y'] # 경도
f.write(emartList['NO'] + '\t' + emartList['NAME'] + '\t' + emartList['ADDRESS'] + '\t'
+ '(' + emartList['MAP_X'] + emartList['MAP_Y'] + ')\n')
f.close()
print('\n\n 조회 및 텍스트파일 생성이 완료되었습니다. \n\n ')
# 종료 확인
requ = int(input('>>> 프로그램 종료 : 1, 계속 : 2 입력해 주세요 : '))
print('\n')
if requ == 2:
continue
else:
break
|
cs |
[1] Python 및 Python 편집기 설치 (tistory.com)
[2] PyCharm 프로젝트 생성 - Hello, PyCharm!! (tistory.com)
[3] STARBUCKS 매장 조회 크롤링 [무작정 따라하기 1] (tistory.com)
[4] STARBUCKS 매장 조회 크롤링 [무작정 따라하기 2] (tistory.com)
[5] 이마트(E-Mart) 매장 조회 크롤링 [무작정 따라하기 3] (tistory.com)
[6] 이마트(E-Mart) 매장 조회 크롤링 - 웹페이지 분석[무작정 따라하기 4] (tistory.com)
반응형
'프로그램ing > Python' 카테고리의 다른 글
[6] 이마트(E-Mart) 매장 조회 크롤링 - 웹페이지 분석[무작정 따라하기 4] (0) | 2022.08.10 |
---|---|
[4] STARBUCKS 매장 조회 크롤링 [무작정 따라하기 2] (0) | 2022.08.03 |
[3] STARBUCKS 매장 조회 크롤링 [무작정 따라하기 1] (0) | 2022.08.03 |
[2] PyCharm 프로젝트 생성 - Hello, PyCharm!! (0) | 2022.07.29 |
[1] Python 및 Python 편집기 설치 (0) | 2022.07.26 |
댓글