Table of Contents
30 Nov 2022
Search Console
Updating new URLs via web interface is a drag. Let's see if I can automate the process with Google's API & Python.
This seems like a good script to test:
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import json
SCOPES= [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT= "https://indexing.googleapis.com/v3/urlNotifications:publish"
# thecodebuzz-da659b2b8b0d.json is the private key that you created for your service account.
JSON_KEY_FILE = "thecodebuzz-da659b2b8b0d.json"
credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)
http = credentials.authorize(httplib2.Http())
url="url-1"
content = {
"url": url,
"type": "URL_UPDATED"
}
response, content = http.request(ENDPOINT, method="POST", body=json.dumps(content))
print(response)
Source:
Python script for Bulk Submit URLs to Google Search Console | TheCodeBuzz
thecodebuzz.com
Sitemap submit:
Sitemaps: submit | Search Console API | Google Developers
google.com