uber busit

In [ ]:
uber busit script
In [29]:
import requests
import getpass
import json
from IPython.display import Image
In [ ]:
 
In [3]:
myusr = getpass.getuser()
In [8]:
with open('/home/{}/mapquest.txt'.format(myusr), 'r') as mapkey:
    thekey = (mapkey.read())
In [10]:
thekey
Out[10]:
'cARVDIBsapEtdKayXOYbdh8KzuIUjDIb\n'
In [11]:
fixkey = thekey.replace('\n', '')
In [12]:
fixkey
Out[12]:
'cARVDIBsapEtdKayXOYbdh8KzuIUjDIb'
In [20]:
with open('/home/{}/uberhisfix.json'.format(myusr), 'r') as uberhistory:
    hisjs = json.loads(uberhistory.read())
In [26]:
hislat = hisjs['history']['start_city']['latitude']
In [27]:
hislon = hisjs['history']['start_city']['longitude']
In [32]:
ubimg = requests.get('http://www.mapquestapi.com/staticmap/v4/getmap?key=' + fixkey + '&size=400,200&zoom=10&center=' + str(hislat) + ',' + str(hislon), stream=True)
In [35]:
r = ubimg.url
In [38]:
with open(ubimg.url, 'wb') as f:
        r.raw.decode_content = True
        shutil.copyfileobj(r.raw, f)        
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-38-3c66a9b395db> in <module>()
----> 1 with open(ubimg.url, 'wb') as f:
      2         r.raw.decode_content = True
      3         shutil.copyfileobj(r.raw, f)

FileNotFoundError: [Errno 2] No such file or directory: 'http://www.mapquestapi.com/staticmap/v4/getmap?key=cARVDIBsapEtdKayXOYbdh8KzuIUjDIb&size=400,200&zoom=10&center=37.7749295,-122.4194155'
In [ ]:
Image(filename='output1.png')

Comments

Comments powered by Disqus