#!/usr/bin/perl -IGoogleProxy

use lib "GoogleProxy";
use strict;
# use warnings;

BEGIN{
	push @INC, "C:\\Users\\Enger\\Documents\\NetBeansProjects\\BuzzerProxy\\src\\googleproxy\\GoogelProxy";
	push @INC, "GoogleProxy";
}

#########################################
##### Author:		Sebastian Enger / B.Sc
##### CopyRight:	Buzzer
##### LastModified	26.1.2008
##### Function:		Hauptdatei für GoogleProxy
##### Todo:			for statt foreach: ist schneller
##### Hint:			minimum StringLength of one Result is about 70 Chars long
########################################

# root: -20 <> 20 | normal: 0 <> 20
my $ServicePriority = "-1";				
# system("renice $ServicePriority $$");

use Socket;
use IO::Select;
use Fcntl ':flock';

use LWP::UserAgent;			# perl -MCPAN -e 'force install "LWP::UserAgent"'	
use HTTP::Cookies;				# perl -MCPAN -e 'force install "HTTP::Cookies"'
use HTTP::Request;				# perl -MCPAN -e 'force install "HTTP::Request"'

use constant VERSION		=> "'GoogleProxy -v1.0.0a- 17.07.2011 @ 13.50 Uhr'";
use constant PIDFILE		=> "googleproxy-pid.txt"; unlink PIDFILE;

my $url = "http://www.google.com/search?hl=en&lr=&q=intitle:\"index of\" +\"last modified\" +\"parent directory\" +description +size+(.png)+Volvagia&btnG=Search";


# create UserAgent object
my $ua = LWP::UserAgent->new();
 
# set a user agent (browser-id)
$ua->agent('Mozilla/5.5 (compatible; MSIE 5.5; Windows NT 5.1)');
 
# timeout:
$ua->timeout(15);
 
# proceed the request:
my $request = HTTP::Request->new('GET');
$request->url($url);
 
my $response = $ua->request($request);
  
# response code (like 200, 404, etc)
my $code = $response->code;
 
# headers (Server: Apache, Content-Type: text/html, ...)
my $headers = $response->headers_as_string;
 
# HTML body:
my $body =  $response->content;


print $code;
print $body;