basic web auth and verification

S

scripteaze

Trying to figure out how to add login verfication. I believe it is
logging me in, but theres no way to really tell..any ideas? or
tutorials out there that can exaplain this to me?

Thanks

import urllib,urllib2,cookielib

passlst = open(passfile, 'r').readlines()
url="http://somesite"
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
TheForm = urllib.urlencode({"username":"myid","password":"mypas"})
request = urllib2.Request(url, TheForm)
result = urllib2.urlopen(request)
html=result.read()
result.close()
 
?

=?ISO-8859-1?Q?Ralf_Sch=F6nian?=

Trying to figure out how to add login verfication. I believe it is
logging me in, but theres no way to really tell..any ideas? or
tutorials out there that can exaplain this to me?

Thanks

import urllib,urllib2,cookielib

passlst = open(passfile, 'r').readlines()
url="http://somesite"
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
TheForm = urllib.urlencode({"username":"myid","password":"mypas"})
request = urllib2.Request(url, TheForm)
result = urllib2.urlopen(request)
html=result.read()
result.close()

I had the same trouble. There was a redirect after login a had to
follow. Look at the following code.

def login(self):
''' Log into web site. '''

self._br.set_handle_redirect(True)
cj = CookieJar()
self._br.set_cookiejar(cj)
self._br.open(Config.urlLogin)
self._br.select_form(name='login')

self._br['session_key'] = Config.username
self._br['session_password'] = Config.password
response=self._br.submit()
self._br.set_response(response)
for link in self._br.links(url_regex="www.somesite.com"):
self._br.follow_link(link)
if 'Sign In' in self._br.title():
raise ValueError('Wrong password')


Regards,
Ralf Schoenian
 
S

scripteaze

(e-mail address removed) schrieb:




Trying to figure out how to add login verfication. I believe it is
logging me in, but theres no way to really tell..any ideas? or
tutorials out there that can exaplain this to me?

import urllib,urllib2,cookielib
passlst = open(passfile, 'r').readlines()
url="http://somesite"
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
TheForm = urllib.urlencode({"username":"myid","password":"mypas"})
request = urllib2.Request(url, TheForm)
result = urllib2.urlopen(request)
html=result.read()
result.close()

I had the same trouble. There was a redirect after login a had to
follow. Look at the following code.

def login(self):
''' Log into web site. '''

self._br.set_handle_redirect(True)
cj = CookieJar()
self._br.set_cookiejar(cj)
self._br.open(Config.urlLogin)
self._br.select_form(name='login')

self._br['session_key'] = Config.username
self._br['session_password'] = Config.password
response=self._br.submit()
self._br.set_response(response)
for link in self._br.links(url_regex="www.somesite.com"):
self._br.follow_link(link)
if 'Sign In' in self._br.title():
raise ValueError('Wrong password')

Regards,
Ralf Schoenian- Hide quoted text -

- Show quoted text -

Thank you very much, ill look into it..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top