I have a list of 80 root domains and want to use Google through its API to search for the most relevant results for a specific keyword, on these 80 root domains.
After that the results need to be enriched with two additional data points: The PageRank for each result, and whether each result is cached in Google.
I need a script for this in PHP.
First of all we require an external config file, in which we can set the Google API key (see [url removed, login to view]), information about the MySQL connection and a maximum number of results for a specific root domain (e.g. max 5 results per root domain).
Second, we need a MySQL table which can hold any number (currently 80) of root domains (e.g. [url removed, login to view], [url removed, login to view] etc) which we want to search through.
Third we need a HTML form where we can input any keyword.
Then the Google API ([url removed, login to view]) should be used to search for the keyword specified at point 3, and search accross only the domains specified in the MySQL table (point 2). Usually you use these kinds of Google queries for that: "keyword site:[url removed, login to view]" ([url removed, login to view]:domain.com&num=10).
Take the top 5 (or whatever is set in the config file at point 1) for each root domain and create a list of all the results.
For all results check if the page is cached in Google ([url removed, login to view]), and display either 'Yes' or 'No'.
After that, for all results check the Google PageRank for the pages (code can be found here: [url removed, login to view]) and display only a number between '0' and '10'.
Then we're finished an got a nice long list of pages, with their cache status and PageRank. As a bonus please create a CSV export for these results.