weezer_316 has asked for the wisdom of the Perl Monks concerning the following question:

Help! WWW::mech gives me unreadable info! Code and output below. Searched everywhere, noone seems to have any ideas on how to fix it.

use WWW::Mechanize; my $url = "http://www.bbc.co.uk"; my $todays_data = "D:\\Documents and Settings\\My Documents\\test_mech +.txt"; my $mech = WWW::Mechanize->new(); $mech->get( $url, ':content_file' => $todays_data ) or die "$!";

Just gives this garbage! Doesnt matter what page I try. On an XP box to, and this code works on linux

ѧcZf'4a%QՆɔ,S d;ƙWg_8?;7RTMه׷G:79'Rʔڈl<mJ?@tM]VڐdX3$~ V?'=#*>2fc" 1(

Replies are listed 'Best First'.
Re: WWW:mech unreadable output
by ikegami (Patriarch) on Feb 24, 2009 at 13:59 UTC
    I can't reproduce that — I guess it serves something different to us Canucks — but I bet you'll find a header saying the content is gzipped.
Re: WWW:mech unreadable output
by poolpi (Hermit) on Feb 24, 2009 at 14:09 UTC

    From WWW::Mechanize doc:

    NOTE: Because :content_file causes the page contents to be stored in a file instead of the response object, some Mech functions that expect it to be there won't work as expected. Use with caution.


    hth,
    PooLpi

    'Ebry haffa hoe hab im tik a bush'. Jamaican proverb
      How does that apply?
Re: WWW:mech unreadable output
by Anonymous Monk on Feb 24, 2009 at 14:17 UTC
    Are you behind some kind of caching proxy?

      OK, your right, wihtout the content file it prints the data normally. think ill just use a normal print then and take it from there. Strange.

      And yes, I am behind a proxy. Im on a coporate LAN. proxy setting are ok though, got them detecting automatically from the environment

      Many thanks for all your help

        WWW::Mechanize replaces the content with the result of $res->decoded_content(), which unzips (among other things) the content