On 11/01/2010 01:07 AM, Dallin Terry wrote:
> I figured that I wouldn't need to set up cookies because one of the
> features listed under the WWW::Mechanize module is "Automatic
> cookies."  It also says, "If you want none of the overhead of a cookie
> jar, or don't want your bot accepting cookies, you have to explicitly
> disallow it."  If this assumption is incorrect, please let me know.
> Here is what I have so far:

I'm not really familiar with either Perl or WWW::Mechanize, but I
believe your assumptions are correct.  After spending 20 minutes
tracking down Perl dependencies in CPAN, and discovering that someone
has a module for Python that's very very close to WWW::Mechanize, I
hacked together a little Python script that works quite well.  Perhaps
you can compare it to your Perl script and see if there's anything you
can use.  My script (with only rudimentary error checking) logs into CAS
and then tries the AIM page.  It seems to let me in quite nicely.

-------------
#!/usr/bin/python

import sys
import mechanize

mech = mechanize.Browser()
mech.open('https://ry.byu.edu')

form = list(mech.forms())[1] #form we want has no name attribute

form['username'] = 'username'
form['password'] = 'password'
request = form.click()

response = mech.open(request)
if response.geturl()[:19] == 'https://cas.byu.edu':
    print 'Login failed.'
    sys.exit(1)

response =
mech.open('https://y.byu.edu/ry/ae/prod/user_help/cgi/mainMenu.cgi')
print response.read()
------------

--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to