Created
December 20, 2017 04:09
-
-
Save JialunC/215d9715fc55982389d424908844f5cf to your computer and use it in GitHub Desktop.
Dropbike nearby bikes HTTP request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests as r | |
import config | |
def find_bikes(lat,lng): | |
result = dict() | |
endpoint = "https://dropbikeadminapi.herokuapp.com/v1/bikes_nearby" | |
data = {"lat":lat,"lng":lng} | |
headers = {"Authorization":config.drop_bike_token,'Content-Type':'application/json','User-Agent':'dropbike/1.9.5 (iPhone; iOS 11.2; Scale/2.00)','Accept-Encoding': 'br, gzip, deflate','X-Dropbike-Platform':'iOS','X-Dropbike-Version':'1.9.5'} | |
# if SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",) occurs | |
# uncomment the following line | |
# r.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':ADH-AES128-SHA256' | |
res = r.post(endpoint,json=data,headers=headers) | |
for x in res.json(): | |
result[x['bicycle_id']] = {'lat': x['lat'], 'lng': x['lng']} | |
return result | |
if __name__ == '__main__': | |
result = find_bikes(44.224593,-76.500387) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment