Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

stripping out some info

by frank1 (Beadle)
on Jan 30, 2022 at 15:48 UTC ( [id://11140965]=perlquestion: print w/replies, xml ) Need Help??

frank1 has asked for the wisdom of the Perl Monks concerning the following question:

My script is working, but am asking how can remove out anything in country field

because now am getting response very well like:

FURRY JEO Country

so i want to remove anything in Country field, because there random digits

use WWW::Mechanize; use WWW::Mechanize::TreeBuilder; use LWP::UserAgent; <!doctype html> <html> <head> </head> <body> <p class='tik-1'>FURRY JEO<span class='info'>Sir</span> Country</p +> </body> </html> my $mech = WWW::Mechanize->new; WWW::Mechanize::TreeBuilder->meta->apply($mech); $mech->get( 'link' ); # Find all <h1> tags my @list = $mech->find('h1'); my @list = $mech->look_down('_tag' => 'p', 'class' => 'result__BigRate-sc-1bsijpp-1 i +GrAod'); foreach (@list) { $Resp = $_->as_text(); print $Resp; }

Replies are listed 'Best First'.
Re: stripping out some info
by Corion (Patriarch) on Jan 30, 2022 at 18:09 UTC

    In your HTML, there is no "country" field.

    I think you will need more detailed parsing instead of simply ->look_down to split up the name and the country.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11140965]
Approved by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found