1 from xml.etree.ElementTree import ElementTree
4 class OpenStreetMapAPI:
5 def __init__(self, username, password):
6 passman = urllib2.HTTPPasswordMgr()
7 passman.add_password("Web Password", "https://api.openstreetmap.org/api/0.6", username, password)
8 authhandler = urllib2.HTTPBasicAuthHandler(passman)
9 self.opener = urllib2.build_opener(authhandler)
11 def user_details(self):
12 response = self.opener.open("https://api.openstreetmap.org/api/0.6/user/details")
14 root = tree.parse(response)
15 user = root.find("user")
17 "id": user.attrib["id"],
18 "display_name": user.attrib["display_name"]