Utilities for automatically submitting website pages for indexing in bulk to Google Search Console
Project description
Google Bulk Indexer
Python script for automatically submitting website pages for indexing in bulk to Google Search Console(GSC). This is a Python version of the original work in google-indexing-script
Functionality
This script submits the website URLs found on a site that you own to GSC for indexing. There is no guarantee that the page requested for indexing will be indexed by Google.
Requirements
- Python >= 3.9
- A Google Cloud account: You will have to create a service account under a Google cloud project and download the private key JSON file.
- GSC account with a verified site (property).
Before you run the tool
Follow the guide by Google Cloud to setup Google Cloud account and service account. You should have the following by the end:
- A google cloud account with a project that has both
Google Search Console API
andWeb Search Indexing API
enabled. - A service account and a private key json file downloaded on your PC.
- The service account email added to your property (site) as Site owner.
Running the tool
- Install the package
pip install gsc-bulk-indexer
-
Copy the private key file that you downloaded from the Google cloud account in the same folder from which you are going to run the tool. Private key is needed for submitting URLs to Google Search Console for indexing.
-
Run the following command to start submitting URLs for indexing
- If you have verified your site as a
Domain
property in GSC run the following command
gsc_bulk_index -p <your-domain.xyz>
OR
python -m gsc_bulk_indexer.submit -p <your-domain.xyz>
- If you have verified your site as a
URL Prefix
property, run the below command
gsc_bulk_index -p https://<your-domain.xyz>
- If you have verified your site as a
If you have the private key json file somewhere else on your PC, you can specify the path while running the script
gsc_bulk_index -c <path to private key file> -p <site domain>
Run the script with --help
to know about command line options.
Use in your application
The indexer comes with caching mechanism to avoid submitting URLs
that have already been submitted. It creates pickle files under .cache
directory in the current working directory. However, if you using the bulk indexer in your application backend, this might not be needed. Below is the recommended usage of the indexer in your application.
from gsc_bulk_indexer import auth
from gsc_bulk_indexer import indexer
def index():
credentials = {
# service account json key dictionary
}
# submit the property URL
gsc_property = "https://example.com"
# OR submit a list of URLs
# urls = ["https://example.com/page1", "https://example.com/page2"]
access_token = auth.get_access_token(credentials=credentials)
if access_token is None:
return
gsc_indexer = indexer.BulkIndexer(
access_token,
property=gsc_property,
# urls=urls, # if you want to submit a list of URLs
use_cache=False, # disable cache to prevent cache files from being created
)
num_urls_submitted = gsc_indexer.index()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gsc_bulk_indexer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f1fe376d25f850771ae315f76d689f10d3c9ae5417cae0dbf1c1321ff694db0 |
|
MD5 | 7c466e9e5b4a6446f9e12d0ad6065ad6 |
|
BLAKE2b-256 | 6941b518a09162d3c80bb0b0ba4f7fd7fbb97741bc9f6cfec8bc7968fa305083 |