I am trying to download a file every 45 minutes from a site. It is a .kmz file which is an overlay you can open in google earth to view. Problem is that the method I am using seems to now work correctly,but gives me a corrupted file. Any help here is my code:
#!/usr/bin/perl -w use strict; use LWP; use WWW::Mechanize; my $now_string = localtime; my $mech = WWW::Mechanize->new(); my $filename = join('_', split(/\W+/, $now_string, -1)); $mech->credentials( '*********' , '***********'); $mech->get('http://datawww2.wxc.com/kml/echo/MESH_Max_180min/') or die + "Error: failed to load the web page"; #print $mech->response()->content(); $mech->follow_link(n => 8) or die "Error: failed to download content"; + $mech->save_content("$filename.kmz");
I am wondering if this is an okay way to obtain those types of files or not? I know the file is corrupted because when I click the link myself and download the file it works fine. The file is a kmz file which is basically an image overlay of weather that can be used on google earth or other web maps. When I open them up in notepad they are very jarbled symbols but look relatively the same. i dont know about the unicode flavor.

In reply to Trouble downloading .KMZ files with www-mechanize by cbouwkamp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.