Home > OS >  python - convert curl command
python - convert curl command

Time:02-11

I have this curl command.

This works

curl -O -H "X-Api:3433432" -X GET "https://website.com/file.zip"

Trying to figure it out how to convert it to something python understands.

curl -O -H "X-Api:3433432" -X GET "https://website/file.zip"

CodePudding user response:

Perhaps you're looking for the "Requests" module? It allows you to create a GET request in a similar way you would use a curl command.

You can find some documentation at: https://www.w3schools.com/PYTHON/ref_requests_get.asp

Edit: There's also https://curlconverter.com/ which should convert it automatically for you.

CodePudding user response:

try using module requests:

import requests

headers = {
    'X-Api': '3433432',
}

response = requests.get('https://website.com/file.zip', headers=headers)
  • Related