This script allows you to download Google Search Query data to a MySQL database as shown in the Search Wilderness Blog by Paul Shapiro
- You already have a Google Search Console account setup with your profiles verified.
- Python 2.7
- Google API Python Client
- CRON (if scheduling)
- MySQL database
- MySQLdb Python library
- Setup a blank MySQL database and insert the credentials into the script
- Connect to your Google Search Console account:
- Visit Google Developer Console
- Create a new Project (it takes a few seconds to load)
- Click Enable API and search for "Google Search Console API". Click the name, then Enable.
- Click Credentials
- Click OAuth Consent Screen and fill in your details
- Click Create Credentials > OAuth Client ID > Other
- Look for the new client ID and click the download button (down arrow)
- Rename the file to
client_secrets.json
- Move it to the same directory as the
searchanalytics2mysql
script
You can use CRON to setup your script as a background task for recurring events. Download analytics data on the 1st of each month.
sudo crontab -e
0 0 1 * * /{path to your script}/searchanalytics2mysql
Press Ctrl + X
then Y
to save and exit the CRON file.
If your searchanalytics2mysql
file is not running, you may need to change the permissions to allow execution.
chmod +x ./searchanalytics2mysql
- 2016/11/04: Improve README, script helpers and make an executable file
- 2015/8/5: Updated script to work with the new Search Analytics API
Copyright (c) 2016 Paul Shapiro and contributors, released under the Apache 2.0 License