Исправлены URL, добавлены User-Agent и Referer в обращении к Nominatim
authorRoman Bazalevskiy <rvb@rvb.name>
Sun, 4 Mar 2018 13:38:33 +0000 (16:38 +0300)
committerRoman Bazalevskiy <rvb@rvb.name>
Sun, 4 Mar 2018 13:38:33 +0000 (16:38 +0300)
pyosmname.py
pyrungps.py

index a0ee16fd392ba7550d5cd2a2686058adf2a7bc10..e6dc29e1ca37e6e468728bd4301e3cf882a64ab0 100644 (file)
@@ -8,7 +8,10 @@ from lxml import etree
 
 def GetXMLDescr(lat,lon):
 
-    req = urllib2.Request("http://nominatim.openstreetmap.org/reverse?lat=%s&lon=%s&accept-language=ru,en" %(lat,lon), None)
+    reqstr = "http://nominatim.openstreetmap.org/reverse?lat=%s&lon=%s&accept-language=ru,en" %(lat,lon)
+    print reqstr
+    headers = { 'User-Agent' : 'PyRunGPS/1.0', 'Referer' : 'https://maps.rvb.name' }    
+    req = urllib2.Request(reqstr, None, headers)
     page = urllib2.urlopen(req).read()
 
     return etree.fromstring(page)
index 31b06959b8d8dd22d322f5acb857785f55631a17..bff314aee32a87d1587c53f9107926d892303494 100644 (file)
@@ -16,7 +16,7 @@ def get_page(uname,year,month):
   
   trainings = []
 
-  req = urllib2.Request("http://www.gps-sport.net/embedCalendar.jsp?userName=%s&year=%s&month=%s"% (uname,year,month), None, {'User-agent': 'Mozilla/5.0'})
+  req = urllib2.Request("http://www.gps-sport.net/services/getMonthlyTrainingDataHTML_V2.jsp?userName=%s&year=%s&month=%s&rnd=0.645673"% (uname,year,month), None, {'User-agent': 'Mozilla/5.0'})
   page = urllib2.urlopen(req).read()
   dom = html.document_fromstring(page)
 
@@ -31,7 +31,9 @@ def get_page(uname,year,month):
 
 def get_gpx_track(trid,name):
 
-  req = urllib2.urlopen("http://www.gps-sport.net/services/trainingGPX.jsp?trainingID=%s" % (trid))
+  print "trid=",trid
+
+  req = urllib2.urlopen("http://www.gps-sport.net/services/trainingGPX.jsp?trainingID=%s&tz=-180" % (trid))
   
   xml = etree.parse(req)