Skip to main content

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

  1. Python >= 3.9
  2. A Google Cloud account: You will have to create a service account under a Google cloud project and download the private key JSON file.
  3. 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 and Web 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

  1. Install the package
pip install gsc-bulk-indexer
  1. 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.

  2. 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 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()

Metadata

Release files for gsc-bulk-indexer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gsc-bulk-indexer 0.1.2
File Size Uploaded
gsc_bulk_indexer-0.1.2.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gsc-bulk-indexer 0.1.2
File Interpreter ABI Platform
gsc_bulk_indexer-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / gsc_bulk_indexer-0.1.2.tar.gz

Download URL gsc_bulk_indexer-0.1.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
43a75076d529074f16311af7af4d4952fe8186ab2f553c26c450ac5dd1ff203b
BLAKE2b-256 checksum
How to use checksums
6382fd625a0ee3afc3b24d13101ac3bf1ed885adf62b1c4b2bd0400f71a70b1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0

Release files / gsc_bulk_indexer-0.1.2-py3-none-any.whl

Download URL gsc_bulk_indexer-0.1.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a58d0b69bc1ed7af241c112928c6c82430e85fe01cb412eda887b974b42fb8cf
BLAKE2b-256 checksum
How to use checksums
3962fad71b5788332d8c85d5ca70ca04c2abbb26a0d56d58c3757d94ca1635af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page