Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Python
➜ web log in using python
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Prashanth Mohan
(2 posts) 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 | Top |
|
Posted by
| Jestre
(13 posts) 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')
| Top |
|
Posted by
| Prashanth Mohan
(2 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | 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.
15,243 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top