[Tutor] Auto login of website

Lloyd Kvam pythontutor at venix.com
Mon Oct 13 13:59:35 EDT 2003


http://unxutils.sourceforge.net/
Native Win32 ports of some GNU utilities

wget is included in the list of utilities.


The python snippet I sent you should be close to working code.  You need
to specify the real URL, username, and password.  A class website is less
likely to have strange cookie requirements than commercial sites.  You might
find that the python code does the trick.

Tony Cappellini wrote:

> Thanks Lloyd
> 
> I dont know what wget is ?
> Is that available for Windows ?
> I need something that works now, as opposed to having to write a program.
> I'm not familair with web programming, and odnt have time to learn now,
> but need to get logged into a wesbtie to work on a project for a class.
> I'd liek to write  a Python version of the auto login program later though
> 
> 
> thanks
> 
> Tony
> 
> 
> On Mon, 13 Oct 2003, Lloyd Kvam wrote:
> 
> 
>>The urllib and urllib2 modules support accessing a website.  The module
>>documentation for urllib describes how to create your own class to
>>override functions provided by urllib.  In your case, you want to
>>override the method:
>>	prompt_user_passwd
>>to return a tuple containing your username and password.
>>
>>import urllib
>>class MyURLopener(urllib.FancyURLopener):
>>     def prompt_user_passwd(host,realm):
>>	#ignore host and realm
>>	# substitue your id and password
>>	return ("mulder", "trustNo1")
>>
>>urllib._urlopener = MyURLopener()
>>
>>f = urllib.urlopen("http://www.some.com")
>>print f.read()
>>
>>This omits cookie issues and other pitfalls.  You may find it easier to
>>use a program like wget to access URL's that have cookies and passwords
>>to control access.
>>
>>Tony Cappellini wrote:
>>
>>>
>>>Would anyone happen to have a small python program (with or without gui)
>>>that can
>>>
>>>log a user into a website, at regular intervals ?
>>>
>>>The program would have to take the following as input (can be
>>>hard-coded, or on the cmd line)
>>>
>>>1. the URL of a website (http)
>>>2. the user ID
>>>3. the user pasword
>>>4. click (simulate a keypress or mouse click) on the button to log the
>>>user in
>>>
>>>if the user could not be logged in, due to the website being overloaded,
>>>then it would do a retry at the next interval (where the interval can be
>>>supplied by the user, preferably in seconds)
>>>
>>>I've already checked the Python Cookbook, didn't find a match for the
>>>keywords I used
>>>
>>>
>>>_______________________________________________
>>>Tutor maillist  -  Tutor at python.org
>>>http://mail.python.org/mailman/listinfo/tutor
>>>
>>
>>--
>>Lloyd Kvam
>>Venix Corp.
>>1 Court Street, Suite 378
>>Lebanon, NH 03766-1358
>>
>>voice:	603-443-6155
>>fax:	801-459-9582
>>
>>
> 
> 
> 

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582




More information about the Tutor mailing list