Search code examples
perllwp

How to fetch a one table from HTML source file using lwp module?


I'm beginner. I want to know how to fetch one table form the source HTML file using LWP module? Is it possible to use Regex with LWP?


Solution

  • You can use LWP to get the HTML source of a web page. Most easily, by using the get() function from LWP::Simple.

    my $html = get('http://example.com/');
    

    Now, in $html you have a text string (potentially a very long text string) which contains HTML. You can use any techniques you want to extract data from that string.

    (Hint: Using a regex to do this is likely to be a very bad idea. It will be far harder than you expect and probably very fragile. Perhaps use a better tool - like HTML::TableExtract instead.)