Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added mech-dump --text

  • Loading branch information...
commit 9c0efd3b07caa8e0cf1fa9338f9805e82997b01f 1 parent 95b0b5b
@petdance petdance authored
Showing with 31 additions and 20 deletions.
  1. +3 −1 Changes
  2. +14 −5 bin/mech-dump
  3. +5 −9 lib/WWW/Mechanize.pm
  4. +9 −5 tags
View
4 Changes
@@ -20,7 +20,9 @@ Schwern.
[ENHANCEMENTS]
New $mech->text method returns the text from your HTML page. The
exact rendering of this text is simply removing all the HTML
-tags, but this may change.
+tags, but this will change. It's pretty ugly.
+
+Added mech-dump --text.
[DOCUMENTATION]
Improvements to the docs explaining explicitly about the subclassed
View
19 bin/mech-dump
@@ -25,11 +25,12 @@ my $cookie_filename;
GetOptions(
'user=s' => \$user,
'password=s' => \$pass,
- headers => sub { push( @actions, \&dump_headers ); },
- forms => sub { push( @actions, \&dump_forms ); },
- links => sub { push( @actions, \&dump_links ); },
- images => sub { push( @actions, \&dump_images ); },
- all => sub { push( @actions, \&dump_headers, \&dump_forms, \&dump_links, \&dump_images ); },
+ headers => sub { push( @actions, \&dump_headers ) },
+ forms => sub { push( @actions, \&dump_forms ) },
+ links => sub { push( @actions, \&dump_links ) },
+ images => sub { push( @actions, \&dump_images ) },
+ all => sub { push( @actions, \&dump_headers, \&dump_forms, \&dump_links, \&dump_images ) },
+ text => sub { push( @actions, \&dump_text ) },
absolute => \$absolute,
'agent=s' => \$agent,
'agent-alias=s' => \$agent_alias,
@@ -49,6 +50,8 @@ Options:
--images Dump table of images
--all Dump all four of the above, in that order
+ --text Dumps the textual part of the web page
+
--user=user Set the username
--password=pass Set the password
--cookie-file=filename Set the filename to use for persistent cookies
@@ -138,6 +141,12 @@ sub dump_images {
return;
}
+sub dump_text {
+ my $mech = shift;
+ $mech->dump_text();
+ return;
+}
+
=head1 SEE ALSO
L<WWW::Mechanize>
View
14 lib/WWW/Mechanize.pm
@@ -2126,23 +2126,19 @@ sub dump_forms {
return;
}
-=head2 $mech->dump_all( [[$fh], $absolute] )
+=head2 $mech->dump_text( [$fh] )
-Prints a dump of all links, images and forms on the current page to
-I<$fh>. If I<$fh> is not specified or is undef, it dumps to STDOUT.
-
-If I<$absolute> is true, links displayed are absolute, not relative.
+Prints a dump of the text on the current page to I<$fh>. If I<$fh>
+is not specified or is undef, it dumps to STDOUT.
=cut
-sub dump_all {
+sub dump_text {
my $self = shift;
my $fh = shift || \*STDOUT;
my $absolute = shift;
- $self->dump_links( $fh, $absolute );
- $self->dump_images( $fh, $absolute );
- $self->dump_forms( $fh, $absolute );
+ print {$fh} $self->text, "\n";
return;
}
View
14 tags
@@ -36,7 +36,6 @@ LocalServer t/local/LocalServer.pm /^package LocalServer;$/;" p
MY Makefile.PL /^sub MY::postamble {$/;" s
MyMech t/local/overload.t /^ package MyMech;$/;" p
NEW_API t/link.t /^NEW_API: {$/;" l
-NONEXISTENT t/autocheck.t /^use constant NONEXISTENT => 'http:\/\/blahblablah.xx-nonexistent.';$/;" c
NON_REGEX_STRING t/find_link-warnings.t /^NON_REGEX_STRING: {$/;" l
NO_AGENT t/new.t /^NO_AGENT: {$/;" l
NO_BASE t/link-base.t /^NO_BASE: {$/;" l
@@ -74,11 +73,10 @@ WWW::Mechanize::Link lib/WWW/Mechanize/Link.pm /^package WWW::Mechanize::Link;$/
_SUPER_put lib/WWW/Mechanize.pm /^sub _SUPER_put {$/;" s
_check_unhandled_parms lib/WWW/Mechanize.pm /^sub _check_unhandled_parms {$/;" s
_clean_keys lib/WWW/Mechanize.pm /^sub _clean_keys {$/;" s
-_content_as_text lib/WWW/Mechanize.pm /^sub _content_as_text {$/;" s
_die lib/WWW/Mechanize.pm /^sub _die {$/;" s
+_extract_forms lib/WWW/Mechanize.pm /^sub _extract_forms {$/;" s
_extract_images lib/WWW/Mechanize.pm /^sub _extract_images {$/;" s
_extract_links lib/WWW/Mechanize.pm /^sub _extract_links {$/;" s
-_format_content lib/WWW/Mechanize.pm /^sub _format_content {$/;" s
_image_from_token lib/WWW/Mechanize.pm /^sub _image_from_token {$/;" s
_is_tainted lib/WWW/Mechanize.pm /^sub _is_tainted {$/;" s
_link_from_token lib/WWW/Mechanize.pm /^sub _link_from_token {$/;" s
@@ -111,18 +109,23 @@ credentials lib/WWW/Mechanize.pm /^sub credentials {$/;" s
creds_required t/local/LocalServer.pm /^sub creds_required {$/;" s
critic Makefile.PL /^critic:$/;" l
ct lib/WWW/Mechanize.pm /^sub ct { my $self = shift; return $self->{ct}; }$/;" s
-current_form lib/WWW/Mechanize.pm /^sub current_form { my $self = shift; return $self->{form}; }$/;" s
+current_form lib/WWW/Mechanize.pm /^sub current_form {$/;" s
delete_header lib/WWW/Mechanize.pm /^sub delete_header {$/;" s
die lib/WWW/Mechanize.pm /^sub die {$/;" s
-dump_all lib/WWW/Mechanize.pm /^sub dump_all {$/;" s
dump_forms bin/mech-dump /^sub dump_forms {$/;" s
+dump_forms bin/mech-dump.orig /^sub dump_forms {$/;" s
dump_forms lib/WWW/Mechanize.pm /^sub dump_forms {$/;" s
dump_headers bin/mech-dump /^sub dump_headers {$/;" s
+dump_headers bin/mech-dump.orig /^sub dump_headers {$/;" s
dump_headers lib/WWW/Mechanize.pm /^sub dump_headers {$/;" s
dump_images bin/mech-dump /^sub dump_images {$/;" s
+dump_images bin/mech-dump.orig /^sub dump_images {$/;" s
dump_images lib/WWW/Mechanize.pm /^sub dump_images {$/;" s
dump_links bin/mech-dump /^sub dump_links {$/;" s
+dump_links bin/mech-dump.orig /^sub dump_links {$/;" s
dump_links lib/WWW/Mechanize.pm /^sub dump_links {$/;" s
+dump_text bin/mech-dump /^sub dump_text {$/;" s
+dump_text lib/WWW/Mechanize.pm /^sub dump_text {$/;" s
field lib/WWW/Mechanize.pm /^sub field {$/;" s
find_all_images lib/WWW/Mechanize.pm /^sub find_all_images {$/;" s
find_all_inputs lib/WWW/Mechanize.pm /^sub find_all_inputs {$/;" s
@@ -183,6 +186,7 @@ success lib/WWW/Mechanize.pm /^sub success {$/;" s
tag lib/WWW/Mechanize/Image.pm /^sub tag { return ($_[0])->{tag}; }$/;" s
tag lib/WWW/Mechanize/Link.pm /^sub tag { return ($_[0])->[3]; }$/;" s
tags Makefile.PL /^tags:$/;" l
+text lib/WWW/Mechanize.pm /^sub text {$/;" s
text lib/WWW/Mechanize/Link.pm /^sub text { return ($_[0])->[1]; }$/;" s
tick lib/WWW/Mechanize.pm /^sub tick {$/;" s
title lib/WWW/Mechanize.pm /^sub title {$/;" s
Please sign in to comment.
Something went wrong with that request. Please try again.