Dhruv Malik
Dhruv Malik

Reputation: 13

Python 3.4 / Requests: Attempting to submit data and receive test file from webpage

I've been attempting to use: http://www.gpsvisualizer.com/elevation to add elevation points to a file of GPS points I have. The file is correctly formatted and works when I manually enter it. I've been attempting to use the Requests package to complete the request for me. I believe the form is a POST request(?) and have been trying:

r = requests.post('http://www.gpsvisualizer.com/elevation', files={'formatted_elevation.csv': open('formatted_elevation.csv', 'rb')})

to receive the page with the added elevation points, however, it doesn't appear to be working.

I'm very new to this area (I'm more of a hardware engineer) and am unsure if I'm completely misunderstanding how to make such a request.

Thanks!

Upvotes: 1

Views: 68

Answers (1)

Alex Woolford
Alex Woolford

Reputation: 4563

I reckon you might be better off using the Google Elevation API instead of scraping the data from gpsvisualizer.com. You'll need to sign-up for an API key (it's free for up to 2,500 requests/day).

It's really easy to use:

>>> import googlemaps 
>>> gmaps = googlemaps.Client(key=[your api key])
>>> gmaps.elevation((39.995, -105.100556))
[{u'resolution': 19.08790397644043, u'elevation': 1606.6650390625, u'location': {u'lat': 39.995, u'lng': -105.100556}}]

There are step-by-step instructions for how to create the API key on Google Maps' Github repo for Python.

Upvotes: 1

Related Questions