in reply to Re: I want to save web pages as text rather than as HTML. -- oneliner
in thread I want to save web pages as text rather than as HTML.

Thanks for all that info. It's a lot to digest.

Despite the elegance of a one-liner, I prefer to take one step at a time.

When I try to run the following code:

use strict; use warnings; use LWP::UserAgent; use LWP::Simple; use HTML::TreeBuilder; print HTML::TreeBuilder->new_from_url('')->as_text;

I get the error message << Can't locate object method "new_from_url" via package "HTML::TreeBuilder" >>

What else do I need to add to the code to make it work?

  • Comment on Re^2: I want to save web pages as text rather than as HTML. -- oneliner
  • Download Code

Replies are listed 'Best First'.
Re^3: I want to save web pages as text rather than as HTML. -- oneliner
by Your Mother (Archbishop) on Sep 10, 2019 at 21:25 UTC

    Maybe you have a really old version and need an update. The method was added 2012-06-12 according to its change file. The example as you posted it works fine for me; relatively current Perl installation with HTML::TB version 5.03 on OS X.

      I was using Padre and DWIM Perl, following Gabor Szabo's instructions at

      I have just uninstalled DWIM Perl and installed Strawberry Perl (64bit) for Windows into C:\Strawberry on my hard drive.

      The README.txt file tells me to run the following commands to manually set some environment variables:

      c:\myperl\ ... this is REQUIRED!

      c:\myperl\ ... this is OPTIONAL

      When I tried to run c:\Strawberry\ I got the error message "The system cannot find the path specified." Hovever, there was a file "relocation.txt" in C:\Strawberry which appeared to run successfully. I can't find any files similar to however.

      I liked the convenince of Padre, but don't want to run into more problems due to not being kept up to date. I also have Notepad++. What to you recommend?

      Thanks for all your help. I'll probably have more questions later.

        Iím really glad people work on Perl on Windows but I donít have the patience for it. It makes everything harder. I tried Padre way back when it was in a very early version and liked what I saw but as far as IDEs goÖ I don't care for them. Forced to choose, maybe Atom, or TextMate on Mac, but I am emacs and I would personally only recommend emacs or vim because they are a baseline you can rely on.

        Try the free Komodo Edit. It's a really excellent Perl IDE with realtime syntax checking, fast and rich interface, hundreds of options, very pleasant colors, snippets, templates, completion, tidy, reliable backups, perfect restorations, support for about a hundred other languages, and lots more.

        One of my favorite features: A few seconds after making a typo or other mistake the lines that will be broken by it are underlined in red, and will popup the warning text on mouseover.