07-11-2012
8 More Discussions You Might Find Interesting
1. Programming
Hello,
I'm coding an application using pthreads.At some point the threads will read some read-only variables.Is it safe NOT to use mutexes, in order to make the program lighter since mutex operations are resource-demanding...
Thanks (1 Reply)
Discussion started by: jonas.gabriel
1 Replies
2. UNIX for Dummies Questions & Answers
okay, i have absolutely no idea what im doing.
i just wanted to make a website, and according to some stuff i read, i needed to have a UNIX account.
sadly, i still dont know what im doing. and i dont want to download anything either, unless absolutely necessary.
is there any way to go about... (1 Reply)
Discussion started by: teahelahn
1 Replies
3. Solaris
trying to run IPERF and i've downloaded and installed and screwed around with my path to get compilers and such available...
log in as myself, go to /iperf-2.0.4
switch to su
run ./configure
seems to go fine, couple of no's but based on previous runs it seems to be ok...
do make
it goes... (3 Replies)
Discussion started by: jrich523
3 Replies
4. Shell Programming and Scripting
hi everybody,
Asking for something that I´m not sure if it´s possible to implement. I hope be clear enough.
Well, my issue is that I´m looking how to copy or extract a particular table content of a website. I get the content from a external feed (Iframe format), the content is updated every... (1 Reply)
Discussion started by: cgkmal
1 Replies
5. Shell Programming and Scripting
Hello Everyone,
I'm trying to write a python script that will go to the following website and grab all the data on the page. The page refreshes regularly and the number of flights is different.
Untitled Document
What I wanted to do was grab all the data (except for top three row containing... (5 Replies)
Discussion started by: jl487
5 Replies
6. Shell Programming and Scripting
hi,
i am very much new to shell scripting i have a requirement that i have to develop a License Renewal Alert system
that has to give a alert mail to the users before 30days of user account expiration, by checking expiration date of the user with the data base, this system will... (0 Replies)
Discussion started by: deepu_Shscripts
0 Replies
7. Shell Programming and Scripting
Hello there,
I am a beginner in Perl, and I have a challenging project:
I have to create a program that checks regularly on an online bank account for new operations, it should then feed a database keeping track of all the money going in and out.
Of course the login details of this online... (4 Replies)
Discussion started by: freddie50
4 Replies
8. Shell Programming and Scripting
good evening,
i'm still new in scripting but i'm learning every day and i'm enjoying it.
so i have api website (htt p://api.nobelprize.org/v1/prize.json), i want to make a script that allows me to give it two arguments like ./test.sh 2005 physics, 2000 is for the year and physics is category... (1 Reply)
Discussion started by: kalbsghir
1 Replies
LEARN ABOUT DEBIAN
www::mechanize::treebuilder
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)