Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: about retrieving and parsing html without writing on disk

by LanX (Cardinal)
on Apr 09, 2018 at 22:15 UTC ( #1212613=note: print w/replies, xml ) Need Help??


in reply to about retrieving and parsing html without writing on disk

hmm, I'm too busy to install the modules, but it's at least possible to open a variable for reading and writing.

open my $fh , "<", \$cache

so if you can operate with filehandles instead of files this should work.

update

HTML::Parser allows ->parse_file($fh) and even ->parse($string)

update

Maybe have a look at $string = $mech->content(...) from WWW::Mechanize

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: about retrieving and parsing html without writing on disk
by rizzo (Chaplain) on Apr 10, 2018 at 00:30 UTC
    Maybe have a look at $string = $mech->content(...) from WWW::Mechanize

    and maybe at HTTP::Response as well, because

    $mech->get( $uri )

    returns an object of that type.

      Good note for checking $response->code and such. Along those lines, for the OP, if you use WWW::Mechanize remember that it fails hard, dies, on any non-success responses, 400s and 500s, unless you set autocheck => 0. You also have access to the response object from the mech object with $mech->response so you don't necessarily need a new variable for it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1212613]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2020-09-30 01:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (156 votes). Check out past polls.

    Notices?