This is something thats been hard for me to find info on, I was fortunate to get an answer on the other thing I was trying to do that relates to this (code below).. so say I am using the $content input (in reality it would be a full HTML page, not just the snippet I gave below) and I want to just get the contents of the input tag that has the name or ID "hush_username". The way it is now it gives the content of all of the input tags.. the only thing that I could find on this mentioned something like incorporating this:
$tag->[1]{name} and $tag->[1]{name} eq "hush_username" ;
But I have been unable to get this to work.. I would greatly appreciate any advice
#!/usr/bin/perl
use strict; use warnings;
use HTML::TokeParser::Simple;
$content = do { local $/; <DATA> };
my $parser = HTML::TokeParser::Simple->new(\$content);
while ( my $tag = $parser->get_tag('input') ) {
print $tag->as_is, "\n";
print "####" ;
for my $attr ( qw( type name value ) ) {
printf qq{%s="%s"\n}, $attr, $tag->get_attr($attr);
}
}
__DATA__
<form name="authenticationform" id="authenticationform"
action="/authentication/login?skin=mobile&next_webapp_name=hushmail5&next_webapp_url_name=m" method="post">
<input type="hidden" name="next_webapp_page" value=""/>
<p><label for="hush_username">Email address:</label><br/>
<input type="email" name="hush_username" id="hush_username" value="[email protected]"/></p>
<p><label for="hush_passphrase">Passphrase:</label><br/>
<input type="password" name="hush_passphrase" id="hush_passphrase" maxlength="1000" value=""/></p>
<p><input type="checkbox" name="hush_remember_me" id="hush_remember_me" value="on"
/><label for="hush_remember_me">Stay signed in when I close my browser</label></p>
<p><input type="submit" value="Sign In"/></p>
<input type="hidden" name="hush_customerid" value="0000000000000000"/>
</form>