Presumably the REASON you want to do this is so you can report how the download is going. If this is what you want to do you will find it easier just to do it with a socket. Say you want something via http

#!/usr/bin/perl use IO::Socket::INET; my $debug = 1; my $get = 'http://www.mysite.com/index.html'; my ( $domain, $stuff ) = $get =~ m!http://([^/]+)(.*)$!; $sock = IO::Socket::INET->new( PeerAddr => $domain, PeerPort => 80, Proto => 'tcp'); die "No socket" unless $sock; print "Got sock\n"; my ( $content, $buffer ); print $sock "HEAD $get HTTP/1.0\015\012\015\012"; $content .= $buffer while ( read ( $sock, $buffer, 1024 ) ); print $content if $debug; die $content unless $content =~ m/200 OK/; my ($content_length) = $content =~ m/^Content-Length:\s*(\d+)/m; print "Content-Length: $content_length\n" if $debug; $content = ''; $sock = IO::Socket::INET->new( PeerAddr => $domain, PeerPort => 80, Proto => 'tcp'); binmode $sock; print $sock "GET $get HTTP/1.0\015\012\015\012"; my $found_crlf = 0; while ( read ( $sock, $buffer, 1024 ) ) { $content .= $buffer; # we need to chop off the header at the first CRLFCRLF if ( ! $found_crlf and index($content, "\015\012\015\012") > 0 ) { $content = substr $content, (index $content, "\015\012\015\012 +") + 4; $found_crlf = 1; } printf "Got %.2f%\n", ( 100* length($content)/$content_length ) if +$debug; } print $content if $debug; __DATA__ Got sock HTTP/1.1 200 OK Date: Sat, 15 Mar 2003 13:07:35 GMT Server: Apache/1.3.26 (Unix) PHP/4.1.2 Last-Modified: Fri, 17 Jan 2003 01:08:19 GMT ETag: "1d0f53-a36-3e275783" Accept-Ranges: bytes Content-Length: 2614 Connection: close Content-Type: text/html X-Pad: avoid browser bug Content-Length: 2614 Got 28.27% Got 67.44% Got 100.00% <html> <head> [blah]

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Capture wget progress bar by tachyon
in thread Capture wget progress bar by rendler

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.