Created
January 28, 2015 02:39
-
-
Save darjeeling/fe58e76e2ed7af6fa1b9 to your computer and use it in GitHub Desktop.
starbucks korea store list crawling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import bs4 | |
import requests | |
import time | |
def main(): | |
for sido_idx in range(1,18): | |
sido = str(sido_idx).zfill(2) | |
gugun_idx = 0 | |
goto_sido = False | |
while True: | |
if goto_sido is True: | |
break | |
gugun_idx += 1 | |
gugun = str(gugun_idx).zfill(2) | |
page_idx = -1 | |
while True: | |
time.sleep(2) | |
page_idx += 1 | |
r = requests.post("http://www.istarbucks.co.kr/Store/store_search2.asp", | |
{"sido" : sido, "gugun": sido + gugun, "PageNo": str(page_idx)}) | |
b = bs4.BeautifulSoup(r.text) | |
items = b.find_all("ul",class_="storeSeachList")[0].find_all("ul") | |
if len(items) == 0: | |
if page_idx == 0: | |
goto_sido = True | |
break | |
for item in items: | |
addr = item.find_all("li")[1].text | |
open("starbucks.text",'a').write(addr.encode("utf8") + "\n") | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/littmus/04e936e5261b4417b670
이디야 커피 매장 리스트 입니다. 커피에선 롯데리아 대신 사용할 수 있을것 같아요.