Reputation: 33
I am trying to execute a curl GET request with python3
the request is:
curl -k -X GET -H "X-Some-Token: s.ggt5gvf344f"https://ip.address:port/v1/path/path
how it can be implemented?
Upvotes: 1
Views: 1919
Reputation: 564
import requests
url = "https://ip.address:port/v1/path/path"
payload={}
headers = {
'X-Some-Token': 's.ggt5gvf344f'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
or you can try http.client library which is much faster than requests
import http.client
conn = http.client.HTTPSConnection("ip.address", port)
payload = ''
headers = {
'X-Some-Token': 's.ggt5gvf344f'
}
conn.request("GET", "/v1/path/path", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Upvotes: 1