Skip to content

Instantly share code, notes, and snippets.

@rbpasker
Created January 29, 2013 22:55
Show Gist options
  • Save rbpasker/4668762 to your computer and use it in GitHub Desktop.
Save rbpasker/4668762 to your computer and use it in GitHub Desktop.
rbp-imac:~ rbp$ python
Python 2.7.2 (default, Jun 16 2012, 12:38:40)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import json, requests
>>>
>>> url = 'http://maps.googleapis.com/maps/api/directions/json'
>>>
>>> params = dict(
... origin='Chicago,IL',
... destination='Los+Angeles,CA',
... waypoints='Joplin,MO|Oklahoma+City,OK',
... sensor='false'
... )
>>>
>>> resp = requests.get(url=url, params=params)
data = json.load(resp)
>>> data = json.load(resp)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 274, in load
return loads(fp.read(),
AttributeError: 'Response' object has no attribute 'read'
>>>
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment