[공공데이터 포털][파이썬][크롤링] 전라북도 전주시 노선정보 서비스
제공 서비스 공통으로 사용하는 함수
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import bs4 def get_parsing(html): bs = bs4.BeautifulSoup(html, 'html.parser') items = bs.find_all('list') lst_items = [] for item in items: dic_atom = {} for atom in item: #print(atom.get_text().strip()) #print(atom.name) dic_atom[atom.name] = atom.get_text() lst_items.append(dic_atom) return lst_items |
노선번호 목록 조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
apiKey = "개발자 apiKey" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_location_all_common.do' queryParams = '?ServiceKey=' + apiKey resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items: print(item) |
노선정보 항목조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
apiKey = "개발자 apiKey" brtId = "165" brtClass = "0" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_location1_common.do' queryParams = '?ServiceKey=' + apiKey + '&brtId=' + brtId + '&brtClass=' + brtClass resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:10]: print(item) |
노선별 경유 정류소 목록 조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
apiKey = "개발자 apiKey" brtStdid = "305001141" lKey = "LOW" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_location_busstop_list_common.do' queryParams = '?ServiceKey=' + apiKey + '&brtStdid=' + brtStdid + '&lKey=' + lKey resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:10]: print(item) |
노선별 형상정보 목록 조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
apiKey = "개발자 apiKey" brtStdid = "305001141" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_nosun_drawing_common.do' queryParams = '?ServiceKey=' + apiKey + '&brtStdid=' + brtStdid resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:25]: print(item) |
노선별 시간표 목록 조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
apiKey = "개발자 apiKey" brtStdid = "305001141" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_location_time_common.do' queryParams = '?ServiceKey=' + apiKey + '&stdId=' + brtStdid resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:10]: print(item) |
저상버스 노선번호 목록조회
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
apiKey = "개발자 apiKey" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/low_location1_list_common.do' queryParams = '?ServiceKey=' + apiKey resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:10]: print(item) |
해당 노선의 상세 추가 정보
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
apiKey = "개발자 apiKey" brtStdid = "305001141" import requests url = 'http://openapi.jeonju.go.kr/jeonjubus/openApi/traffic/bus_location_busstop_info_common.do' queryParams = '?ServiceKey=' + apiKey + '&stdId=' + brtStdid resp = requests.get(url + queryParams) html = resp.content html = html.decode('utf8') # utf8 string으로 변환 lst_items = get_parsing(html) for item in lst_items[:10]: print(item) |