#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use HTTP::Cookies;
use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new( agent => 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' );
$mech->autoclose_tab( 0 );

# http://idea-buddy.com/ideas/ .  int(rand(10))
# http://idea-buddy.com/ideas/334444


#MozRepl -> Firefox > F10

my $count = 0;
while(1){
	print "$count call \n";
	my $r = int(rand(4000));
	&main2($r);
	$count++;
}


sub main2(){
	my $t = shift;
	$mech->get( 'http://idea-buddy.com/ideas/' . $t );
	
	 open(W,"+>>./ideas_log.txt");
		binmode(W);
		print W $mech->content(raw => 1);
		print W "\n\n\n###############\n\n";
	close W;
		print "Success: " .$mech->success() . "\n";
		print "Status: " .$mech->status() . "\n";
		
}

exit 0;
