gsc.py is a Python script designed to authenticate with Google Search Console, retrieve search analytics data, and generate comprehensive reports. The script processes queries, clicks, impressions, CTR, and position metrics, then saves the results in Excel and CSV formats.
- Authenticates with Google Search Console.
- Retrieves search analytics data for a specific property and date range.
- Aggregates metrics such as:
- Total clicks and impressions.
- CTR as a percentage.
- Average position (weighted by impressions).
- Outputs the processed data into:
- Excel (
search_analytics_data.xlsx) - CSV (
search_analytics_data.csv)
- Excel (
- Python 3.6+
- Google API Client Library (
googleapiclient) - Pandas (
pandas) - OpenPyXL (
openpyxl)
- Clone or download this repository.
- Place the
gsc.pyfile in your working directory. - Update the following variables in
gsc.pyas needed:property_uri: The URL of your Google Search Console property (e.g.,https://www.example.com/).start_date: The start date for the data retrieval (format:YYYY-MM-DD).end_date: The end date for the data retrieval (format:YYYY-MM-DD).
- Run the script:
python gsc.py
- The script generates two files in the script's directory:
search_analytics_data.xlsx: A detailed Excel report.search_analytics_data.csv: A CSV version of the report.
- Ensure you have enabled the Google Search Console API and have the necessary credentials for authentication.
- The script uses
googleapiclient.sample_toolsfor authentication.
This project is open-source and available under the MIT License.