import json, urllib
def get_geocode(text, key):
try:
data = urllib.urlopen("http://geocode-maps.yandex.ru/1.x/?","geocode="+text+"&key="+key+"&format=json&").read()
return json.loads(data)
except Exception, e:
return None
print get_geocode("Киров, Первомайский район, улица Большевиков, 16", "AHqsEk4BAAAAekkFTAMA9DGkZfo_WT9ci8K8X286J9ILWjIAAAAAAAAAAABhqxW74U1xylQQhCYKzVIxsQBPTQ==")
Вот так всё просто
from xml.dom.minidom import parse, parseString
dom1 = parse('Desktop/002.xml')
def get_value_text(node, name):
if node.getElementsByTagName(name).length and node.getElementsByTagName(name)[0].childNodes.length:
return node.getElementsByTagName(name)[0].childNodes[0].data
return ""
for d in dom1.getElementsByTagName("Контрагент"):
name = get_value_text(d, "НаименованиеТочки")
address = "%s %s %s %s %s %s" % (get_value_text(d, "Город"), get_value_text(d, "Район"), get_value_text(d, "НасПункт"), get_value_text(d, "Улица"), get_value_text(d, "Дом"), get_value_text(d, "Корпус"))
print get_geocode(address, "AHqsEk4BAAAAekkFTAMA9DGkZfo_WT9ci8K8X286J9ILWjIAAAAAAAAAAABhqxW74U1xylQQhCYKzVIxsQBPTQ==")