python - convert curl command

154
March 26, 2022, at 8:10 PM

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"
Answer 1

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.

Answer 2

try using module requests:

import requests
headers = {
    'X-Api': '3433432',
}
response = requests.get('https://website.com/file.zip', headers=headers)
Rent Charter Buses Company
READ ALSO
AssertionError inside of ensure_local_distutils when building a PyInstaller exe using setuptools/distutils

AssertionError inside of ensure_local_distutils when building a PyInstaller exe using setuptools/distutils

I am trying to convert some Python code into anexe with PyInstaller

239
Function to return current half quarter and previous two quarters based on current date

Function to return current half quarter and previous two quarters based on current date

I would like to create a variable (suffix) that prints current year and quarter in this format: '_21_q2' and (previous_suffix) which is simply suffix - 2 quarters in this case: '_21_q2'

148
Custom train-test split using two stratified classes

Custom train-test split using two stratified classes

I am trying to use NLP techniques to predict the mental status of patients at the time doctor's notes were takenI have two classes, suffix (multilabel) as well as mental_status (binary, Lucid or Delirium)

184