As discussed, I think it would be handy to be able to pre-process HTML
before submitting a form via WWW::Mechanize.
In this case, I wanted to submit an Option to a Select input that was
not in the original HTML.
Cheers,
Magnus
18:38 <Magnus> do you use HSBC internet banking?
18:38 <Andy> No sir.
18:39 <Magnus> well, I'm automating the downloading of statements
18:39 <Andy> ok
18:39 <Magnus> and the first thing it shows you is a <SELECT>
18:39 <Magnus> but it only shows a year of statements at a time
18:39 <Magnus> each option is a different month
18:39 <Magnus> so it'd be nice to submit the form for months that aren't
on that particular page
18:39 <Magnus> I'll just change my algorithm
18:39 <Andy> huh.
18:39 <Magnus> but it'd definitely be good to be able to override
18:39 <Andy> It's more than a Mech issue.
18:40 <Magnus> oh ok
18:40 <Andy> I believe that HTML::Form won't let you do it.
18:40 <Magnus> the parser behind it?
18:40 <Magnus> fair enough
18:40 <Andy> It's HTML::Form that squawks.
18:40 <Magnus> Illegal value '2004-07-01' for field 'statementDate' at
/usr/local/perl580/lib/site_perl/5.8.0/WWW/Mechanize.pm line 474
18:40 <Magnus> it's no biggy
18:40 <Andy> What version of Mech you on?
18:41 <Magnus> 0.74
18:41 <Magnus> just what happeend to be here, iirc
18:42 <Andy> Just wanna see what line 474 is.
18:42 <Andy> Yup,, it's HTML::Form that is complaining.
18:43 <Magnus> ah well
18:43 <Magnus> I could probably reconstruct the form
18:43 <Andy> It's funny how Mech has put all this new stress on
HTML::Form.
18:43 <Magnus> but I'll just have it iterate through the pages
18:43 <Andy> You could ALSO....
18:44 <Andy> wait, let me see if I added this yet.
18:45 <Andy> Write a subclass of mech
18:45 <Andy> that overrides the _parse_html() method
18:45 <Magnus> oh goodness
18:45 <Magnus> not for this project :)
18:45 <Magnus> it's nearly finished
18:45 <Magnus> thanks though
18:45 <Andy> that modifies $self->{content} and then calls
SUPER::_parse_html()
18:45 <Andy> no no, hold on. It's simple.
18:45 <Andy> That's ALL it has to override.
18:46 <Andy> and it modifies that before the parsing.
18:46 <Magnus> oh... interesting
18:46 <Andy> so it's doing your form tweaking on the fly, instead of you
doing it statically.
18:46 <Magnus> yeah
18:46 <Magnus> I get the idea
18:46 <Magnus> I've half written my iterating functino now though :)
18:46 <Andy> Maybe I need a page_preprocess method or something.
18:47 <Andy> so you could then call
18:47 <Andy> my $mech = WWW::Mechanize->new( preprocess =>
\&magnus_function_that_sticks_last_years_statements_in_the_select );
18:47 <Andy> Because I get the feeling that many people are in your
boat.
18:48 <Magnus> it seems like something thing people might want to do
18:49 <Andy> Starting with you.
18:49 <Andy> Do me a favor, if you would pleaes.
18:49 <Andy> Send a quick little email describging your situation to
bug-www-mechanize@rt.cpan.org
18:49 <Magnus> sure
18:49 <Andy> so that I don't lose track of it.
18:49 <Magnus> I'll do it now
18:49 <Andy> I haven't looked at Mech in a while, so maube it's time.
18:49 <Andy> heck, you could cut&paste this IRC log. :-)
18:50 <Andy> ok, I'm off to lunch. Thanks.
18:50 <Magnus> ok
18:50 <Magnus> heh, I'm having dinner...