Python Https Authentication

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

Python Https Authentication
BASIC authentication with Python bottle
Try IAM Database Authentication from Python
Authentication using tweepy-User authentication and application authentication (Python)
[Python] Use Basic/Digest authentication with Flask
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Python comprehension
Python technique
Studying python
Python memorandum
Python FlowFishMaster
Python service
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
Python comprehension
install python
Python Singleton
Passwordless authentication with RDS and IAM (Python)
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python memo
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python sys.intern ()
Python tutorial
Python decimals
python underscore
Python summary
Start python
Note: Python
Setting up Basic authentication using Python @Lambda
Python basics ③
python log
Python basics
[Scraping] Python scraping
Python update (2.6-> 2.7)
python memo
Python memorandum
Python # sort
ufo-> python
Python nslookup
python learning
Hannari Python 2020
[Rpmbuild] Python 3.7.3.