use strict;
use warnings;
use HTML::Entities;
my $url = 'https://www.google.com/search?tbm=bks&';
my $userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36';
print "\n\nPlease enter the query you would like to scrape.\n";
my $query = ;
$query =~ s/^\s+|\s+$//g;
print "\nHow many pages?\n";
my $maxPages = ;
$maxPages =~ s/^\s+|\s+$//g;
print "\nOutput folder?\n";
my $folder = ;
$folder =~ s/^\s+|(\\|\/)?\s+$//g;
my $file = "$folder/$query-$maxPages.json";
my %hash;
print "\nFetching...\n";
for(my $i = 0; $i < $maxPages; $i++)
{
my $fullUrl = $url . "q=$query";
if($i != 0)
{
$fullUrl .= "&start=$i" .0;
}
print "Getting this: $fullUrl\n";
my $html = `curl -A "$userAgent" -k "$fullUrl"`;
#print "HTML: $html";
#;
#Disclaimer: kids, don't parse HTML like this at home
#it's bad for your health/sanity ;)
my @sections = split /div class="rc"/, $html;
shift @sections;
for my $section (@sections)
{
my $title;
my $desc;
if($section =~ /