[Tutor] urllib help

Timothy M. Brauch tbrauch@mindless.com
Sun Feb 9 14:06:06 2003


I am trying to use urllib to open a webpage.  However, I have hit a small
problem.  The page I want to open is password protected and you have to log
in to view it.  It's not that big of a problem because I know the username
and password (it is my website).  I am not sure how to send this data
through.

Here is an interactive session:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE Fork 0.8 -- press F1 for help
>>> import urllib
>>> source = urllib.urlopen('http://192.168.0.1')
Enter username for server at 192.168.0.1: mylogin
Warning: Problem with getpass. Passwords may be echoed.
Enter password for admin in DI-614+ at 192.168.0.1: mypassword

How can I send mylogin and mypassword?  I am trying to write a script that
will run on its own, without my intervention to retrieve a file for me.

 - Tim