-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path할리스커피매장 크롤링.py
35 lines (32 loc) · 1.23 KB
/
할리스커피매장 크롤링.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
from bs4 import BeautifulSoup
import urllib.request
import pandas as pd
import datetime
#Hollys커피 매장 크롤링
def hollys_store(result):
for page in range(1,59):
Hollys_url = 'https://www.hollys.co.kr/store/korea/korStore.do?pageNo=%d&sido=&gugun=&store=' %page
print(Hollys_url)
html = urllib.request.urlopen(Hollys_url)
soupHollys = BeautifulSoup(html, 'html.parser')
tag_tbody = soupHollys.find('tbody')
for store in tag_tbody.find_all('tr'):
if len(store) <= 3:
break
store_td = store.find_all('td')
store_name = store_td[1].string
store_sido = store_td[0].string
store_address = store_td[3].string
store_phone = store_td[5].string
result.append([store_name]+[store_sido]+[store_address]
+[store_phone])
return
def main():
result = []
print('Hollys store crawling >>>>>>>>>>>>>>>>>>>>>>>>>>')
hollys_store(result)
hollys_tbl = pd.DataFrame(result, columns=('store', 'sido-gu', 'address','phone'))
hollys_tbl.to_csv('./hollys2.csv', encoding='cp949', mode='w', index=True)
del result[:]
if __name__ == '__main__':
main()