I used to be able to code fluently, but after a year in the military (so far) and recently only being able to code on windows machines, I'm left confused about many things like when I first started. Don't think that languages aren't perishible knowledge.
Anyhow, here's my code, it just grabs a image every few seconds and -tries- to write it to disk. The problem is that it doesn't write the image correctly. I compared the files and the differences are sooo tiny (one or two bytes difference) it looks like the file gets corrupted. No idea.
Any help, appreciated much! Again this is on win xp with uhh Activestate ActivePerl 5.8.0.
require HTTP::Request; require HTTP::Response; require LWP::UserAgent; while( 1 ) { $ua = LWP::UserAgent->new; $request = HTTP::Request->new( GET => "$url" ); $response = $ua->request( $request ); if ( $response->is_success ) { ( $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst ) = localtime( time ); my $content_dump = ( ($year += 1900) . ".$mon.$hour.$min.$sec.jpg" + ); open( PICDUMP, ">$outputbase/$content_dump" ) || die( "Couldn't open $outputbase/$content_dump ($!)" ); print( PICDUMP $response->content ) || die( "Couldn't print to file ($!)" ); print( STDOUT "Wrote $content_dump\n" ); close( PICDUMP ); sleep 4; } else { print $response->error_as_HTML; } }
In reply to grabbing a image with HTTP module by Cat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |