On Sat, 29 May 2004, bruce wrote: > hi... Hi
[...] > basically, i'm looking to be able to get class schedule information from the > http://lca.lehman.cuny.edu/dept/registrar/schedule/coursefinder.asp site. [...] #!/usr/bin/perl -w use WWW::Mechanize; my $b = WWW::Mechanize->new(); $b->get("http://lca.lehman.cuny.edu/dept/registrar/schedule/coursefinder.asp"); $b->form_number(0); print $b->current_form()->dump(); $b->field("u_input", "CHE"); $b->field("sortby", "Instructor"); open(F, ">out.html"); print F $b->submit()->content(); close(F) or you could defect <wink>: http://wwwsearch.sf.net/mechanize/ #!/usr/bin/env python import mechanize b = mechanize.Browser() b.open("http://lca.lehman.cuny.edu/dept/registrar/schedule/coursefinder.asp") b.select_form(nr=0) print b # I confess this is actually a bit of an accident (see below) b["u_input"] = ["CHE"] b["sortby"] = ["Instructor"] f = open("out.html", "w") f.write(b.submit().read()) f.close() Why does 'print b' print the current form? Because Browser delegates all unknown attribute access to ClientForm.HTMLForm. .__str__() is one such method. For almost everything, this is useful, but it's not really what one wants in this particular case. Since mechanize (the Python module) is still alpha (though fairly dilute of bugs, I believe), I shall go away now and add Browser.form_as_string() and Browser.__str__() methods :-) John