[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  web log in using python

web log in using python

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Prashanth Mohan   (2 posts)  [Biography] bio
Date Tue 22 Nov 2005 12:41 PM (UTC)
Message

Hello

I am new to python programming. I want to do a project which calculates the broadband usage for a particular ISP. How can i get the pages after logging into a website?

i understand that i will have to use the urllib2 library. I have been trying to read the docs, but however i could not figure out how to use it's functions.

How can i pass username, password to a website and get the logged in webpage? also this site works only for IE, so i will have to set the user string too.

Thank You

Prashanth
[Go to top] top

Posted by Jestre   (13 posts)  [Biography] bio
Date Reply #1 on Wed 23 Nov 2005 01:47 AM (UTC)
Message
Something like this perhaps? I got it from the Python Manual.


import urllib2
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'host', 'username', 'password')
opener = urllib2.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib2.install_opener(opener)
urllib2.urlopen('http://www.example.com/login.html')

[Go to top] top

Posted by Prashanth Mohan   (2 posts)  [Biography] bio
Date Reply #2 on Wed 23 Nov 2005 06:23 AM (UTC)
Message

yes

but in this case.. what would the values of 'realm' and 'host' be?
auth_handler.add_password('realm', 'host', 'username', 'password')

i assume host would be the website ip where login is to be done. but what about realm? shouldnt that be obtained from the server?

Thank You

Prashanth
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 23 Nov 2005 07:49 PM (UTC)
Message
Quote:

I want to do a project which calculates the broadband usage for a particular ISP


This is bit off-topic for this forum which is basically about clients and servers for MUD games (multi-user dungeons). If someone wants to answer, fine, but otherwise I suggest going to a general Python or programming forum.

I googled for "add_password" and got 791 matches, so perhaps some of those could help you?


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,693 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]