How to put results of subprocess in a variable
Question: I can retrieve my data only by using cURL, I think subprocess is the easier
way to do it but I cannot put the data in a variable.

For example like this

    
    
    data = subprocess.call('curl "URL" -X GET', shell=True)
    

Is there any easy way to do this via python?


Answer: If you are trying to do this with subprocess and want the result of the call,
then you are looking for `check_output`:

    
    
    data = subprocess.check_output(["curl", URL])
    

However, I suggest you use the [requests](http://docs.python-
requests.org/en/latest/) library in Python for what you are doing. Full of
features that will make your life easier.

Here is a simple example on using requests:

Make sure you have installed requests first. It is not a built-in library. The
URL I linked will explain how to do this.

    
    
    >>> import requests
    >>> d = requests.get("http://www.google.ca")
    >>> print(d)
    <Response [200]>
    

There is a bunch of data you can get from that response. If you do a `d.text`,
you will get the text response. I suggest you read the doc to understand how
to use it. It is a fully featured library with tons of features.

I suggest looking through the docs for all the other stuff you want.

