%PDF- %PDF-
Direktori : /proc/thread-self/root/opt/hc_python/share/doc/pycurl/examples/quickstart/ |
Current File : //proc/thread-self/root/opt/hc_python/share/doc/pycurl/examples/quickstart/form_post.py |
#! /usr/bin/env python # -*- coding: utf-8 -*- # vi:ts=4:et import pycurl try: # python 3 from urllib.parse import urlencode except ImportError: # python 2 from urllib import urlencode c = pycurl.Curl() c.setopt(c.URL, 'https://httpbin.org/post') post_data = {'field': 'value'} # Form data must be provided already urlencoded. postfields = urlencode(post_data) # Sets request method to POST, # Content-Type header to application/x-www-form-urlencoded # and data to send in request body. c.setopt(c.POSTFIELDS, postfields) c.perform() c.close()