#!/usr/bin/perl $| = 1; use strict; use LWP::UserAgent; use POSIX; use IO::File; my $ua = LWP::UserAgent->new (); my $fh = IO::File->new ( "pollcheck.csv", O_APPEND | O_WRONLY | O_CREAT ); while ( 1 ) { my $response = $ua->get ( 'http://www.livejournal.com/poll/?id=1192029' ); if ( $response->is_success ) { my $html = $response->content (); my @res = ( $html =~ /
(\d+)\..+?(\d+)<\/b>.+?<\/p>/sg ); my @firstPos = @res[0..29]; my %firstPos = @firstPos; printf $fh "%s;", strftime ( "%Y-%m-%d %H:%M:%S", localtime ); foreach my $key ( sort { $a <=> $b } keys %firstPos ) { printf $fh "%s;", $firstPos{ $key }; } print $fh "\n"; } else { printf $fh "%s;error retrieving page\n"; } $fh->flush (); sleep 30; } $fh->close ();