class - requests (HTTP 連線)

 

 


 

myPost.py

#!/usr/bin/env python

import requests

url = 'http://datahunter.org/debug.php'
myobj = {'somekey': 'somevalue'}

r = requests.post(url, json = myobj, 
                  auth=("user","pass"),
                  headers={'myHeader': '1234'})

print(r.status_code)
print(r.headers['content-type'])
print(r.text)

Creative Commons license icon Creative Commons license icon