π Automated sitemap-based URL indexing for Google Search Console
A Python tool that automatically extracts URLs from your sitemap and submits them to Google Search Console for indexing. This tool streamlines the process of getting your web pages indexed by Google, saving you time and ensuring comprehensive coverage of your site.
- πΊοΈ Automatic Sitemap Parsing - Extracts URLs from XML sitemaps
- π OAuth 2.0 Authentication - Secure Google API integration
- π Browser-based Auth - No manual code copying required
- π Multi-port Support - Automatically tries different ports for local server
- π Batch Processing - Submit multiple URLs efficiently
- β‘ Rate Limiting - Respects Google API quotas
- π Detailed Logging - Comprehensive logging for debugging
- π‘οΈ Error Handling - Robust error recovery and retry mechanisms
- π Progress Tracking - Real-time processing status
- π― Daily Limits - Configurable daily processing limits
- π Resume Processing - Automatically skips previously processed URLs
- π Environment Variable Support - Secure credential management
- Python 3.7+
- Google Cloud Console project with Search Console API enabled
- OAuth 2.0 credentials configured
-
Clone the repository
git clone <repository-url> cd google_search_index
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
in .env set GOOGLE_CLIENT_SECRET_FILE=path/to/your/client_secret_file.json
-
Configure Google Cloud Console (See Setup Guide for detailed instructions)
-
Set environment variable for your client secret file
# Example export GOOGLE_CLIENT_SECRET_FILE="./client_secret_1092233429048-mkdns68ootdslvpm8gupah7udl1bb08u.apps.googleusercontent.com.json"
-
Run the tool
python google_search_index_api.py
-
Authenticate when prompted in your browser
-
Monitor progress in the terminal
| Variable | Description | Required | Example |
|---|---|---|---|
GOOGLE_CLIENT_SECRET_FILE |
Path to your Google OAuth client secret JSON file | Yes | ./client_secret_*.json |
The tool comes with sensible defaults that you can customize:
# In main() function
sitemap_url = "https://textmachine.org/sitemap.xml" # Your sitemap URL
index_type = 1 # 1: Register, 0: Delete
daily_limit = 200 # URLs per day
start_offset = 0 # URLs to skip from beginning| Setting | Description | Default | Options |
|---|---|---|---|
sitemap_url |
URL of your XML sitemap | https://textmachine.org/sitemap.xml |
Any valid sitemap URL |
index_type |
Operation type | 1 (Register) |
1 = Register, 0 = Delete |
daily_limit |
Max URLs per run | 200 |
Any positive integer |
start_offset |
URLs to skip from beginning | 200 |
Any non-negative integer |
# Set environment variable first
export GOOGLE_CLIENT_SECRET_FILE="./your_client_secret.json"
# Run the tool
python google_search_index_api.py# Set environment variable
set GOOGLE_CLIENT_SECRET_FILE=./your_client_secret.json
# Run the tool
python google_search_index_api.pyEdit the sitemap_url in main() function:
sitemap_url = "https://yoursite.com/sitemap.xml"Change index_type to 0:
index_type = 0 # Delete URLs from indexThe tool automatically saves processed URLs to processed_urls.txt and skips them on subsequent runs. You can also set a start offset:
start_offset = 400 # Skip first 400 URLs2024-01-15 10:30:45,123 [INFO] === Google Search Console Indexing Tool ===
2024-01-15 10:30:45,124 [INFO] Sitemap URL: https://textmachine.org/sitemap.xml
2024-01-15 10:30:45,125 [INFO] Operation type: Index registration
2024-01-15 10:30:45,126 [INFO] Daily limit: 200
2024-01-15 10:30:45,127 [INFO] Starting Google API authentication...
2024-01-15 10:30:50,234 [INFO] Authentication completed successfully!
2024-01-15 10:30:51,345 [INFO] Extracted 150 URLs from sitemap.
2024-01-15 10:30:51,346 [INFO] Starting index registration with Google Search Console...
2024-01-15 10:30:52,456 [INFO] [1/150] Processing: https://textmachine.org/page1
2024-01-15 10:30:53,567 [INFO] Result: {'notifyTime': '2024-01-15T10:30:53.567Z'}
- Daily Limit: 200 URLs (configurable)
- Rate Limiting: 1 request per second (built-in)
- Google API Quota: 200 requests per day (free tier)
- Progress Tracking: Automatically resumes from where you left off
| Issue | Cause | Solution |
|---|---|---|
Environment variable not set |
Missing GOOGLE_CLIENT_SECRET_FILE |
Set the environment variable with correct file path |
redirect_uri_mismatch |
OAuth URIs not configured | See Setup Guide |
access_denied |
No Search Console permissions | Verify domain ownership in Search Console |
Port already in use |
Local server port conflict | Tool automatically tries different ports |
API quota exceeded |
Daily limit reached | Wait 24 hours or request quota increase |
Check the log file for detailed information:
tail -f google_indexing.loggoogle_search_index/
βββ google_search_index_api.py # Main application
βββ requirements.txt # Python dependencies
βββ SETUP_GUIDE.md # Detailed setup instructions
βββ README.md # This file
βββ google_indexing.log # Runtime logs
βββ auto_token.pickle # OAuth token (auto-generated)
βββ processed_urls.txt # Processed URLs tracking (auto-generated)
βββ client_secret_*.json # Your Google OAuth credentials
- OAuth tokens are stored locally in
auto_token.pickle - Client secret files contain sensitive information - keep them secure
- Use environment variables for credential file paths
- Never commit credential files to version control
- Add
client_secret_*.jsonandauto_token.pickleto.gitignore
- Processing Speed: ~1 URL per second (API rate limit)
- Memory Usage: Minimal (< 50MB)
- Disk Usage: < 1MB (excluding logs)
- Resume Capability: Automatically continues from previous session
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Search Console API
- Google OAuth 2.0
- Python community for excellent libraries
- π Setup Guide - Detailed configuration instructions
- π Issues - Report bugs or request features
- π¬ Discussions - Community support
Made with β€οΈ for better SEO and web indexing