Use Python / urllib to access websites using siteminder authentication?

I am trying to access and analyze a website at work using Python. Site authorization is performed through siteminder, so the usual password for the user urllib / urllib2 does not work. Does anyone have an idea how to do this? thanks to NoamM

+3
source share
3 answers

First of all, you should find out what happens during authentication through siteminder. Perhaps there is documentation there, but if it's not so difficult to find out: the Network tab in the Chrome or Safari developer tools contains all the necessary information: HTTP headers and cookies for each network request. Firebug can also give you this.

Once you have a clear idea of ​​what happens at each step of the authentication process, it is only a matter of replicating the same behavior in your script. urllib2 supports cookies and. If you need something that urllib2 does not give, PycURL will probably do.

+1
source

- , . Siteminder . , , .

+1

- , - , . # - , siteminder - . request.session() , cookie - , , . , , .

output.text , , xpath - .

import requests
r = requests.session()
postUrl = "https://loginUrl"
params = {  'USER': 'user',
            'PASSWORD': 'pass',
            'SMENC': 'ISO-8859-1',
            'SMLOCALE': 'US-EN',
            'target': '/redir.shtml?GOTO=redirecturl}',
            'smauthreason': '0' }

r.post(postUrl, data=params)

getUrl = "http://urlFromBehindLogInYouWantDataFrom"
output = r.get(getUrl)
print(output.text)
+1

All Articles