Smells like a job for HTML::Treebuilder! Which in turn uses HTML::Parser, which in turn uses HTML::Element, which in turn provides you with the ridiculously powerfull look_down method... Assuming $content contains the page you got back;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new;
$tree->parse($content);
$tree->eof;
my @hidden_field_elements = $tree->look_down(
_tag => "input",
type => "hidden",
);
my %hidden_fields =
map { $_->attr('name') => $_attr('value') }
@hidden_field_elements;
This might work as it is, or it may have some typos in there. You get the <IMG> tag though... Uh... picture.
I must recommend that you not use this method though, because it makes solving this challenge so easy it can only be considered cheating. And you don't wanna be a cheat right?
The man-pages for HTML::Element, ::Parser and ::TreeBuilder are also criminally complete and can easily be used to convince any PHP'r that he's barking up the wrong (pear)tree.
Happy coding!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.