Curl in python

Do you want to know the information regarding “Curl in python”. If yes, you’re in the correct post.

Curl in python

import requests

headers = 
    'Content-type': 'application/json',

data=""text":"Hello, World!""

response ='', headers=headers, data=data)
import shlex
cmd = '''curl -X POST -d  '"nw_src": "", "nw_dst": "", "nw_proto": "ICMP", "actions": "ALLOW", "priority": "10"' http://localhost:8080/firewall/rules/0000000000000001'''
args = shlex.split(cmd)
process = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
import requests
res = requests.get('')
import requests
r = requests.get('')
import pycurl
import StringIO

response = StringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, '')
c.setopt(c.WRITEFUNCTION, response.write)
c.setopt(c.HTTPHEADER, ['Content-Type: application/json','Accept-Charset: UTF-8'])
c.setopt(c.POSTFIELDS, '@request.json')
print response.getvalue()
payload =  'key' : 'val' 
headers = 
res =, data=payload, headers=headers)


I hope this tutorial helps you to know about “Curl in python”. If you have any questions regarding this article please let us know via the comment section. Share this article with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment