8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello everyone,
I've got some problem intalling a perl module.
The installation is well done as you can see below.
gueg@ux31:~$ sudo apt-get install libwww-mechanize-perl
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état...... (4 Replies)
Discussion started by: tot94
4 Replies
2. Shell Programming and Scripting
Hello,
Am very new to perl , please help me here !!
I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file.
below is the script which i have written so far ,
#!/usr/bin/perl
use LWP::UserAgent;
use... (2 Replies)
Discussion started by: scott_cog
2 Replies
3. Shell Programming and Scripting
hi gurus ,
i want the command to get the output in the desired format .
basically to convert columns to rows.
please refer to the attachment. (3 Replies)
Discussion started by: r_t_1601
3 Replies
4. Shell Programming and Scripting
Hello
Today I had a beautiful test to write some commands using Ubuntu, now I want to make sure of my answers to be reassured, if I had a mistake please correct me
List all files details under ubuntu Desktop.
my answer:
cd Desktop |ls -l
Navigate to your Desktop directory and... (7 Replies)
Discussion started by: S4K
7 Replies
5. Programming
We've been running perl scripts using the www::mechanize module on a linux box with no issues, however we just implemented the same scripts on an aix machine, aix 6.1, perl 5.8.8, and I am running into the issue with Content_Encoding: gzip in the returned html. I can't read it in that it is coming... (0 Replies)
Discussion started by: islanderman
0 Replies
6. UNIX for Dummies Questions & Answers
Hi All'
I'm a newbe, and just is started to learn unix.
Where can I find a complete sample scripts? I looking for a sample scripts which log in at another unix host and and execute another script server side.
Any input welcome (5 Replies)
Discussion started by: ioniCoder
5 Replies
7. Shell Programming and Scripting
So, I've just started learning Perl, and I've decided to read up on some modules. I encountered WWW::Mechanize, which interests me, so I decided to try out a couple of basic tutorials. One of them is found here. I tried what seems a very basic case:
#!/usr/bin/perl
use WWW::Mechanize;
$url... (1 Reply)
Discussion started by: treesloth
1 Replies
8. Answers to Frequently Asked Questions
Every now and then our users post complete programs to this site. It is especially important that these contributions don't get lost, so I will collect them here. Some of these programs are intended to demonstrate a programming technique and some are ready to run. As a guideline, the code... (0 Replies)
Discussion started by: Perderabo
0 Replies
WWW::Mechanize::TreeBuilder(3pm) User Contributed Perl Documentation WWW::Mechanize::TreeBuilder(3pm)
NAME
WWW::Mechanize::TreeBuilder - Module to optimize WWW::Mechanize and HTML::TreeBuilder use
SYNOPSIS
use Test::More tests => 2;
use Test::WWW::Mechanize;
use WWW::Mechanize::TreeBuilder;
# or
# use WWW::Mechanize;
# or
# use Test::WWW::Mechanize::Catalyst 'MyApp';
my $mech = Test::WWW::Mechanize->new;
# or
#my $mech = Test::WWW::Mechanize::Catalyst->new;
# etc. etc.
WWW::Mechanize::TreeBuilder->meta->apply($mech);
$mech->get_ok('/');
is( $mech->look_down(_tag => 'p')->as_trimmed_text, 'Some text', 'It worked' );
DESCRIPTION
This module combines WWW::Mechanize and HTML::TreeBuilder. Why? Because I've seen too much code like the following:
like($mech->content, qr{<p>some text</p>}, "Found the right tag");
Which is just all flavours of wrong - its akin to processing XML with regexps. Instead, do it like the following:
ok($mech->look_down(_tag => 'p', sub { $_[0]->as_trimmed_text eq 'some text' })
The anon-sub there is a bit icky, but this means that anyone should happen to add attributes to the "<p>" tag (such as an id or a class) it
will still work and find the right tag.
All of the methods available on HTML::Element (that aren't 'private' - i.e. that don't begin with an underscore) such as "look_down" or
"find" are automatically delegated to "$mech->tree" through the magic of Moose.
METHODS
Everything in WWW::Mechanize (or which ever sub class you apply it to) and all public methods from HTML::Element except those where
WWW::Mechanize and HTML::Element overlap. In the case where the two classes both define a method, the one from WWW::Mechanize will be used
(so that the existing behaviour of Mechanize doesn't break.)
USING XPATH OR OTHER SUBCLASSES
HTML::TreeBuilder::XPath allows you to use use xpath selectors to select elements in the tree. You can use that module by providing
parameters to the moose role:
with 'WWW::Mechanize::TreeBuilder' => {
tree_class => 'HTML::TreeBuilder::XPath'
};
# or
# NOTE: No hashref using this method
WWW::Mechanize::TreeBuilder->meta->apply($mech,
tree_class => 'HTML::TreeBuilder::XPath';
);
and class will be automatically loaded for you. This class will be used to construct the tree in the following manner:
$tree = $tree_class->new_from_content($req->decoded_content)->elementify;
You can also specify a "element_class" parameter which is the (HTML::Element sub)class that methods are proxied from. This module provides
defaults for element_class when "tree_class" is "HTML::TreeBuilder" or "HTML::TreeBuilder::XPath" - it will warn otherwise.
AUTHOR
Ash Berlin "<ash@cpan.org>"
LICENSE
Same as Perl 5.8, or at your option any later version of Perl.
perl v5.10.1 2010-12-16 WWW::Mechanize::TreeBuilder(3pm)