This script automatically inspects your new blog posts using Google Search Console’s URL Inspection API. It provides detailed indexing status and helps identify potential issues with your posts. Note: Google has deprecated the programmatic indexing request API, so this script focuses on inspection and monitoring.
http://localhost:8080/http://localhost:8081/http://localhost:9090/http://localhost/ (for fallback)credentials.json in this directoryMake sure your website is verified in Google Search Console.
Install Python Dependencies:
pip install -r requirements.txt
Place Credentials:
credentials.json in this directoryConfigure the Script (optional):
config.json on first runSubmit posts modified in the last 7 days:
python submit_posts.py
Submit posts modified in the last 3 days:
python submit_posts.py --mode recent --days 3
Submit posts changed since the last commit:
python submit_posts.py --mode git
Submit posts changed since 5 commits ago:
python submit_posts.py --mode git --since HEAD~5
Submit posts changed since a specific commit:
python submit_posts.py --mode git --since abc1234
python submit_posts.py --mode url --url "https://thinhdanggroup.github.io/your-post-title/"
Test what would be submitted without actually submitting:
python submit_posts.py --dry-run
Enable detailed logging:
python submit_posts.py --verbose
The script uses a config.json file for configuration. Here are the available options:
{
"site_url": "https://thinhdanggroup.github.io/",
"base_url": "https://thinhdanggroup.github.io",
"posts_pattern": "*.md",
"excluded_files": ["README.md", "index.md"],
"rate_limit_delay": 1.0,
"max_urls_per_batch": 10
}
site_url: Your site URL as registered in Google Search Consolebase_url: Base URL for generating post URLsposts_pattern: Glob pattern to match post filesexcluded_files: Files to exclude from submissionrate_limit_delay: Delay between API requests (seconds)max_urls_per_batch: Maximum URLs to submit in one batchOn first run, the script will:
The tokens are saved in token.json and will be automatically refreshed as needed.
Add to your crontab to run daily:
# Submit new posts daily at 9 AM
0 9 * * * cd /path/to/script && python submit_posts.py --mode recent --days 1
Add to your GitHub Actions workflow:
- name: Submit new posts to Google Search Console
run: |
cd script/google_search_console
python submit_posts.py --mode git --since $
env:
GOOGLE_APPLICATION_CREDENTIALS: $
Run after deploying new content:
# In your deployment script
python script/google_search_console/submit_posts.py --mode recent --days 1
“Credentials file not found”
credentials.json exists in the script directory“Permission denied”
“Rate limit exceeded”
rate_limit_delay in config.jsonmax_urls_per_batch“Invalid URL format”
OAuth/Redirect URI Issues
http://localhost:8080/http://localhost:8081/http://localhost:9090/http://localhost/Run with verbose logging to see detailed information:
python submit_posts.py --verbose --dry-run
credentials.json and token.json secure.gitignore to avoid committing to version controlThis script complements your existing IndexNow script (../indexnow/main.py). You can run both:
Consider running both scripts in sequence for maximum search engine coverage.