Home > Software engineering >  export gpx file with python?
export gpx file with python?

Time:03-07

i want to export (download) a gpx file from enter image description here

using python i want to export the gpx file after inserting a new loc=lat-lon&loc=lat-lon to the url. after inspecting the site this the span class to download.

enter image description here

please guys. at least a hint

CodePudding user response:

It seems it uses JavaScript to get data from API as JSON and it creates data in memory (blob with gpx data), and when you click it then it sends data (blob) directly from memory - so there is no URL to get it. And when I use click() then it asks for folder and this needs manual click.

It seems it is simpler to get JSON than gpx - and url to JSON also use -0.0898,51.514739;-0.096656,51.516214

import requests

url = 'https://routing.openstreetmap.de/routed-bike/route/v1/driving/-0.0898,51.514739;-0.096656,51.516214?overview=false&alternatives=true&steps=true'

response = requests.get(url)

data = response.json()

for point in data['waypoints']:
    print('name:', point['name'])
    print('distance:', point['distance'])
    print('location:', point['location'])
    print('---')

Result:

name: Princes Street
distance: 4.955845
location: [-0.089734, 51.514722]
---
name: Gresham Street
distance: 8.8597
location: [-0.096605, 51.516287]
---
  • Related