Proper way to extract JSON data from the web given an API
Question: I have an URL in the form of

    
    
    http://site.com/source.json?s=
    

And I wish to use Python to create a class that will allow me to parse in my
"s" query, send it to that site, and extract out the JSON results.

I've tried importing json/setting up the class, but nothing ever really works
and I'm trying to learn good practices at the same time. Can anyone help me
out?


Answer: Ideally, you should (especially when starting out), use the
[requests](http://docs.python-requests.org/en/latest/) library. This would
enable your code to be:

    
    
    import requests
    r = requests.get('http://site.com/source.json', params={'s': 'somevalue/or other here'})
    json_result = r.json()
    

This automatically escapes the parameters, and automatically converts your
JSON result into a Python dict....

