WWW::Google::WebmasterTools::Download - Extract data from Google Webmaster Tools
This distribution is a rip-off of Stephan Schmitz's php-webmaster-tools-downloads library which can be found on Github at https://github.com/eyecatchup/php-webmaster-tools-downloads.
This project provides an easy way to automate downloading of data tables from Google Webmaster Tools and storing the results in CSV files.
It performs these actions essentially by scraping Google Webmaster Tools, because the GWT API does not provide full access to all the data desired.
It is necessary because GWT only shows you data for the last three months, so if you want to track your website for longer than that you have to store the data separately yourself.
use WWW::Google::WebmasterTools::Download;
my $gdata = WWW::Google::WebmasterTools::Download->new(
email => 'example@gmail.com',
password => 'correct horse battery staple',
);
my @data = $gdata->get_content_keywords_data(
website => 'http://www.example.org',
);
$gdata->save_top_queries_as_csv(
website => 'http://www.example.org',
filename => 'content_keywords_data.csv'
);
Takes an email and password and returns an object with methods to access data from Google Webmaster Tools.
my $gdata = WWW::Google::WebmasterTools::Download->new(
email => 'example@gmail.com',
password => 'correct horse battery staple',
);
Immediately logs in and pre-caches all your site URLs which can be slow if you have a large number of them or a slow internet connection.
Optionally takes a regular expression for filtering on which sites you are interested in; a language (ISO 639-1 2-letter language code); and a user agent.
my $gdata = WWW::Google::WebmasterTools::Download->new(
email => 'example@gmail.com',
password => 'correct horse battery staple',
sites_regex => qr/example/,
language => 'de',
ua => LWP::UserAgent->new(agent => "My Agent Name"),
);
The default sites regex matches all sites, the default language is 'en', and the default user agent has the UserAgent string WWW::Google::WebmasterTools::Download.
Returns a list of sites available for the user. Obeys the sites_regex parameter passed to new().
my @sites = $gdata->get_sites;
Each of these takes a website and returns an array of arrayrefs representing a table of data.
my @data = $gdata->get_top_pages_data(
website => 'http://www.example.org'
);
Each of these takes a website and a filename and writes a CSV file with the data for that website.
$gdata->save_top_queries_as_csv(
website => 'http://www.example.org',
filename => 'example_org_top_queries.csv',
);