Download Now free .ipynb file:
Free Link for ipynb file that can be used further in google colab.
Download now free google drive link
Notice: For this to work you have to make sure the service account that you are giving is also added in google search console for that property or url as owner (Do that in settings)
Just Bulk Urls part (paste inside google colab):
Manual .ipynb file:
If you don't want to download because of trust issues you can just copy the following code and save it as .ipynb file or whatever format google colab takes.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "0uGYx5rzEjaJ"
},
"source": [
"## **Instant Indexing For Blogger Website's Using Google API**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "QqBWFgLlFQpF"
},
"outputs": [],
"source": [
"#@title **Connect Your Google Drive**\n",
"#@markdown **To use this method, you have to connect your Google Drive everytime you Refresh/Disconnect/Reset this notebook in order to use the files saved in your drive but no need to re-upload the file again**\n",
"\n",
"#@markdown **Provide Yes > Execute the cell**\n",
"Connect_Google_Drive = \"Yes\" #@param [\"Yes\", \"No\"]\n",
"if Connect_Google_Drive == \"Yes\":\n",
" from google.colab import drive\n",
" drive.mount('/content/drive')\n",
" print(\"Successfully Connected!\")\n",
"else:\n",
" print(\"Not Connected!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "HgmMnKOBQcdR"
},
"outputs": [],
"source": [
"#@title **Provide Complete Path Of The API Key Here**\n",
"API_Path = \"/content/drive/MyDrive/API_Key.json\" #@param {type:\"string\"}\n",
"\n",
"from oauth2client.service_account import ServiceAccountCredentials\n",
"import httplib2\n",
"\n",
"SCOPES = [\"https://www.googleapis.com/auth/indexing\"]\n",
"ENDPOINT = \"https://indexing.googleapis.com/v3/urlNotifications:publish\"\n",
"print('*'*50);print(\"Scopes & Endpoint Configured...\");print('*'*50);print(\"Adding Key...\");print('*'*50);\n",
"# service_account_file.json is the private key that you created for your service account.\n",
"JSON_KEY_FILE = API_Path\n",
"print(\"Key Added Successfully!\");print('*'*50);\n",
"credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)\n",
"http = credentials.authorize(httplib2.Http())\n",
"print(\"Credentials Successfully Authorized!\");print('*'*50);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "VuJ-Pt1eS8mT"
},
"outputs": [],
"source": [
"#@title **Provide Site URLs & Update Request Types**\n",
"#@markdown Provide a list of site URLs and their corresponding update request types. Make sure the URLs are ownership verified websites.\n",
"\n",
"siteURLs = [\"https://cryptobool.com/blog/the-rise-of-central-bank-digital-currencies-cbdcscryptocurrency-mining-how-does-it-work-and-is-it-profitable/\",\"https://cryptobool.com/blog/the-rise-of-central-bank-digital-currencies-cbdcscryptocurrency-mining-how-does-it-work-and-is-it-profitable/\",\"https://cryptobool.com/blog/what-is-interaction-to-next-paint-inp/\"]#@param {type:\"raw\"}\n",
"\n",
"requestType = \"URL_UPDATED\" #@param [\"URL_UPDATED\", \"URL_DELETED\"]\n",
"\n",
"contents = []\n",
"for urll in siteURLs:\n",
" print(urll)\n",
" content = str({'url': urll, 'type': requestType})\n",
" contents.append(content)\n",
"\n",
"print(\"RESULT:\")\n",
"print('*' * 50)\n",
"print(\"URLs and Update Request Types Configured!\")\n",
"print('*' * 50)\n",
"\n",
"\n",
"for content in contents:\n",
" response, content = http.request(ENDPOINT, method=\"POST\", body=content)\n",
" output = response['status']\n",
"\n",
" if output == '200':\n",
" print(\"Successfully Done!\");print('*'*50);\n",
" else:\n",
" print(\"Error Code: {}\".format(output));print('*'*50);\n",
" print(\"Visit Here For More: https://developers.google.com/search/apis/indexing-api/v3/core-errors#api-errors\");\n",
" print('*'*50);"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "API Indexing For Blogger By Tech Bhavesh",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}