Advertisement
Guest User

ForPav

a guest
Feb 26th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. import requests, json
  2.  
  3. #Private map quest key used for authentication
  4. key = "Fmjtd%7Cluu8210zl1%2Cbl%3Do5-94rxdr"
  5.  
  6.  
  7. def urlBuilder(key):
  8.     url = "http://open.mapquestapi.com/directions/v2/optimizedroute?key="
  9.     url += key
  10.     return url
  11.  
  12. url = urlBuilder(key)
  13.  
  14. masterRequest = {}
  15.  
  16. request = []
  17.  
  18. tempInput = {"street":"1455 Montreal Rd",
  19.                 "city":"Tucker",
  20.                 "county":"DeKalb",
  21.                 "state":"GA"}
  22.  
  23. request.append(tempInput)
  24.  
  25. tempInput2 = {"street":"495 Winn Way",
  26.                 "city":"Decatur",
  27.                 "county":"DeKalb",
  28.                 "state":"GA"}
  29.  
  30. request.append(tempInput2)
  31.  
  32. tempInput3 = {"street":"80 Jesse Hill Jr. Drive SE",
  33.                 "city":"Atlanta",
  34.                 "county":"Fulton",
  35.                 "state":"GA"}
  36.  
  37. request.append(tempInput3)
  38.  
  39. masterRequest["location"] = request
  40.  
  41. inputJson = json.dumps(masterRequest, sort_keys = False)
  42.  
  43.  
  44. #print inputJson
  45.  
  46. #inputJson = inputJson.replace(" ", "")
  47.  
  48. #print inputJson
  49.  
  50. #url += inputJson
  51.  
  52. #print url
  53. print json.dumps(masterRequest, sort_keys = False, indent = 4, separators = (',', ': '))   #use for pretty printing
  54.  
  55. #print "HERE IS CHARACTER 0: " + inputJson[0]
  56. #print inputJson[0]
  57. r = requests.post(url, json=inputJson)
  58.  
  59. #print inputJson
  60.  
  61. #print url
  62.  
  63. #r = requests.get(url)
  64.  
  65. print (r.url)
  66.  
  67. print (r.content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement