[BangPypers] Auto Login to Website and Capturing more details

kracekumar ramaraju kracethekingmaker at gmail.com
Tue Dec 27 17:37:19 CET 2011


Hi

Try requests, this is possible with it, use authentications in requests.


On Tue, Dec 27, 2011 at 9:28 PM, Nikunj Badjatya
<nikunjbadjatya at gmail.com>wrote:

> Noufal,
>
> I tried with :
> {{{
> import urllib, urllib2, cookielib
>
> username = 'xxx'
> password = 'xxx'
>
> savepage = open('output.html', 'w')
>
> #cj = cookielib.CookieJar()
> #opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
>
> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
> login_data = urllib.urlencode({'username' : username, 'j_password' :
> password})
> opener.open('https://ebpp.airtelworld.com/pkmslogin.form', login_data)
>
> resp = opener.open('
>
> https://ebpp.airtelworld.com/cares/wps/myportal/!ut/p/.cmd/cs/.ce/7_0_A/.s/7_0_J5/_s.7_0_A/7_0_J5
> ')
>
> savepage.write(resp.read())
> savepage.close()
>
>
> }}}
>
> The link in the 'resp' is true to my knowledge. I checked it by logging in
> at diff times. Its coming the same every time and it is the link behind
> 'Account Information' which comes on the front page after logging in.
>
> When I open output.html, Its giving me the same login form i.e same looks
> as those of 'https://ebpp.airtelworld.com/pkmslogin.form'
>
> I tried with CookieJar() also. Same results.
>
> Any ideas?
>
> Thanks,
>
> Nikunj
>
>
> --
> *7*Switch off as you go |*q*Recycle always | P Save Paper - Save Trees | Go
> Green
>
>
>
> On Fri, Dec 23, 2011 at 1:29 AM, Saager Mhatre <saager.mhatre at gmail.com
> >wrote:
>
> > On Thu, Dec 22, 2011 at 10:27 PM, Noufal Ibrahim <noufal at gmail.com>
> wrote:
> >
> > > [snip]
> > >
> >
> > >
> > The Python stdlib can handle this using urllib2 and cookielib. I've
> managed
> > > something like this here
> > https://gist.github.com/3811b566df4005a012c7which you can use as a
> > starting point.
> > >
> > > After this, you have a session. Now you should be able to GET the URL
> you
> > > want directly and parse it for the information you need.
> > >
> >
> > Wouldn't something like mechanize
> > <http://pypi.python.org/pypi/mechanize>simplify all this?
> >
> > - d
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
*
Thanks & Regards

"Talk is cheap, show me the code" -- Linus Torvalds
kracekumar
www.kracekumar.com
*


More information about the BangPypers mailing list