title: CURL request to Python as command line
body: <p>Currently, I'm trying to convert CURL request to Python script.</p>
  
  <pre><code>curl $(curl -u username:password -s https://api.example.com/v1.1/reports/11111?fields=download | jq ".report.download" -r) &gt; "C:\sample.zip"
  </code></pre>
  
  <p>I have tried pycurl, with no success, due to knowledge limitation.</p>
  
  <p>As a solution, I have found, that it is possible to run commands through python.
  <a href="https://www.raspberrypi.org/forums/viewtopic.php?t=112351" rel="nofollow noreferrer">https://www.raspberrypi.org/forums/viewtopic.php?t=112351</a></p>
  
  <pre><code>import os
  os.system("curl -K.........")
  </code></pre>
  
  <p>And other solution ( based on the search more common) using subprocess</p>
  
  <pre><code>import subprocess
  
  subprocess.call(['command', 'argument'])
  </code></pre>
  
  <p>Currently, I'm not sure where to move and how to adapt this solution to my sitionation.</p>
  
  <pre><code>import os
  
  os.system("curl $(curl -u username:password -s https://api.example.com/v1.1/reports/11111?fields=download | jq '.report.download' -r) &gt; 'C:\sample.zip'")
  
  'curl' is not recognized as an internal or external command,
  operable program or batch file.
  255
  </code></pre>
  
  <p><strong>P.S. - Update v1</strong></p>
  
  <p>Any suggestion?</p>
  
  <pre><code>import requests
  
  response = requests.get('https://api.example.com/v1.1/reports/11111?fields=download | jq ".report.download" -r', auth=('username', 'password'))
  </code></pre>
  
  <p>This work without "<code>| jq ".report.download</code>" this part, but this is the main part which gives at the end only link to download the file.</p>
  
  <p>ANy way around it?</p>