Here is my Code snippet to request google indexing using python.
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
# service_account_file.json is the private key that you created for your service account.
JSON_KEY_FILE = "myJSON.json"
credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)
http = credentials.authorize(httplib2.Http())
# Define contents here as a JSON string
content = """
{
"url": "https://locksro.weebly.com/",
"type": "URL_UPDATED"
}"""
#send the request
response, content = http.request(ENDPOINT, method="POST", body=content)
print(response.status)
To ensure that the Link Indexed, I check it by searching {site:locksro.weebly.com} in google, but no result. I cannot figure out the problem as the response.status is 200
question from:https://stackoverflow.com/questions/65889022/google-indexing-api-with-python