Skip to main content

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsc_bulk_indexer-0.1.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gsc_bulk_indexer-0.1.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file gsc_bulk_indexer-0.1.2.tar.gz.

File metadata

  • Download URL: gsc_bulk_indexer-0.1.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0

File hashes

Hashes for gsc_bulk_indexer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 43a75076d529074f16311af7af4d4952fe8186ab2f553c26c450ac5dd1ff203b
MD5 39433ed3650247f98cea7e0c1f3ecbe6
BLAKE2b-256 6382fd625a0ee3afc3b24d13101ac3bf1ed885adf62b1c4b2bd0400f71a70b1a

See more details on using hashes here.

File details

Details for the file gsc_bulk_indexer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gsc_bulk_indexer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0

File hashes

Hashes for gsc_bulk_indexer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a58d0b69bc1ed7af241c112928c6c82430e85fe01cb412eda887b974b42fb8cf
MD5 48b1bb252b762cc41924166c2f07e2a1
BLAKE2b-256 3962fad71b5788332d8c85d5ca70ca04c2abbb26a0d56d58c3757d94ca1635af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page