in reply to RobotUA not working

I've checked the documentation and other than the fact that you've reported libwww5.76 and CPAN shows libwww-perl-5.76, I can find no discrepancy between what you have here and what the documentation says you should have.

LWP::RobotUA has a very similar example to what you have. You may want to increase your delay somewhat: you have 1 second; default is 1 minute; doco suggests 10 minutes is being nice! Regardless of this, the syntax and return value are as expected.

LWP::UserAgent states the get() method returns a HTTP::Response object: exactly what you have here.

The HTTP::Response documentation describes the methods this object can invoke. Have a read to find out about retrieving header/content/status/etc. information.

I can't comment on what would have happened last week: you haven't provided details and I wasn't there.

PN5

Replies are listed 'Best First'.
RobotUA not working
by mkurtis (Scribe) on Mar 07, 2004 at 02:20 UTC
    Last week it returned HTML so that content printed out the page source, i was relying on it doing this so i could parse it for links, but that didnt happen. Thanks for the HTTP::response refferal.I try that.
    Thanks again

      There's a few things you can check. First, compare your old code with your new script. Either of the following two code fragments would result in the behaviour you're reporting. (Assuming, of course, a content-type of text/html.)

      # Chaining methods $content = $ua->get($uri)->content; print $content; # Providing content to 'print()' via method print $content->content;

      Another possibility, albeit fairly remote, is that your reinstallation of the modules overwrote some customisations in the previous installation. (Never discount even remote possibilities as swngnmonk found in his hell which is debugging and I can atest to from personal experience.)

      Lastly, I'd suggest renaming the variable $content (perhaps to $response) to avoid any confusion with the method content() and also to more accurately reflect the data it holds.

      PN5

        Wow PN5 it prints HTML now, thanks alot! Is there any particular reason why i cant set my delay so that i requests faster than a minute. i have it set for 10 seconds
        $ua->delay(10/60)
        but it still takes a minute to print. Also when i try to parse content using HTML::Parser it gives me this
        HTML::Parser=HASH(0x826f6b4)
        i tried putting ->parse at the end of the code like this
        $p->parse($content)->parse;
        and leaving the second parse off, but i still get the Hash(.....). I looked at CPAN's docs, but they all seem to say that i am using it correctly.
        Thanks