Python-HTTP-Authentifizierung

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-HTTP-Authentifizierung
BASIC-Authentifizierung mit Python-Flasche
Versuchen Sie die IAM-Datenbankauthentifizierung von Python aus
Authentifizierung mit Tweepy-User-Authentifizierung und Anwendungsauthentifizierung (Python)
Kafka Python
Python-Grundlagen ⑤
Python-Zusammenfassung
Python-Einschlussnotation
Python-Technik
Python studieren
Python-Memorandum
Python FlowFishMaster
Python-Dienst
Python-Tipps
Python-Funktion ①
Python-Grundlagen
Python-Memo
Ufo-> Python (3)
Python-Einschlussnotation
Installieren Sie Python
Python Singleton
Passwortlose Authentifizierung mit RDS und IAM (Python)
Python-Grundlagen ④
Python-Memorandum 2
Python-Memo
Python Jinja2
Python-Inkrement
atCoder 173 Python
[Python] -Funktion
Python-Installation
Python installieren 3.4.3.
Versuchen Sie Python
Python-Memo
Python iterativ
Python-Algorithmus
Python2 + word2vec
[Python] -Variablen
Python sys.intern ()
Python-Tutorial
Python-Fraktion
Python Underbar Das ist was
Python-Zusammenfassung
Starten Sie Python
Hinweis: Python
Einrichten der Basisauthentifizierung mit Python @Lambda
Python-Grundlagen ③
Python-Protokoll ausgeben
Python-Grundlagen
[Scraping] Python-Scraping
Python-Update (2.6-> 2.7)
Python-Memo
Python-Memorandum
Python #sort
Ufo-> Python
Python nslookup
Python lernen
[Rpmbuild] Python 3.7.3.