Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- #-*- coding: utf-8 -*-
- import requests
- import json
- ROUTES_URL = 'http://car.hccepb.gov.tw/TMap/MapGISData.asmx/Get_DDLRouteList'
- STOP_INFO_URL = 'http://car.hccepb.gov.tw/TMap/MapGISData.asmx/GetStopInfo'
- HEADERS = {
- 'Content-Type': 'application/json'
- }
- def get_routes():
- return json.loads(
- json.loads(
- requests.post(
- ROUTES_URL,
- headers=HEADERS
- ).text
- )['d']
- )
- def get_stop_info(route_id=1):
- return json.loads(
- json.loads(
- requests.post(
- STOP_INFO_URL,
- headers=HEADERS,
- data=json.dumps({'run_id': route_id}),
- ).text
- )['d']
- )
- a = get_routes()
- for x in a:
- print x['run_id'], x['name'].encode('utf-8')
- for x in a:
- print json.dumps(get_stop_info(x['run_id']), ensure_ascii=False, indent=2).encode('utf-8')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement