in reply to RobotUA not working
in thread RobotUA not working

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

Replies are listed 'Best First'.
Re: Re: RobotUA not working
by mkurtis (Scribe) on Mar 07, 2004 at 05:46 UTC
    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

      I'm glad it's working.

      Regarding the delay, the reason is simply etiquette; the same applies to honouring the requests in the robots.txt file.

      PN5

      Second Reply - Following Update

      I'm detecting either a misunderstanding or a lack of knowledge regarding the way Perl represents object references. This may help:

      my $q = CGI->new; print $q; # outputs CGI=HASH(0xhhhhhhh) my $fh = IO::File->new; print $fh; # outputs IO::File=GLOB(0xhhhhhhh) # Format is: # <module-name>=<blessed-reference-type>(0x<hex-memory-location>)

      Most HTML::Parser methods return an HTML::Parser object. This is what you are outputting. You'll need to supply code in order for me to supply more information :-)

      I haven't used this module previously so I wrote a test script to see what's going on. I've posted it after the 'Read more ...', hopefully you'll find something useful there.

      The HTML::Parser documentation includes about half-a-dozen example (working) scripts.

      PN5

        Thanks PN5 before i read this i did find some code similar to yours, now it works, thanks for replying though, I did post another Parser question in Seekers of Perl wisdom regarding word combining.
        Thanks