filename.py
# -*- coding: utf_8 -*-
import urllib,urllib2
import sys
def test ():
sys.argv.pop(0)
ids = sys.argv[0]
branchName = sys.argv[1]
resourceId = sys.argv[2]
filesId = sys.argv[3]
txt = "hello world"
print 'txt:', txt
mydata=[('ids',ids),('txt',txt)]
mydata=urllib.urlencode(mydata)
path='https://xxxx.xx.xx.php'
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None,path,"username","password")
opener = urllib2.build_opener(urllib2.HTTPSHandler(),urllib2.HTTPBasicAuthHandler(password_mgr))
urllib2.install_opener(opener)
req=urllib2.Request(path, mydata)
req.add_header("Content-type", "application/x-www-form-urlencoded")
page=urllib2.urlopen(req).read()
print page
if __name__ == '__main__':
test()
Recommended Posts