This script fetches keywords from a remote JSON file, processes them, and submits them to the Google Indexing API. It ensures that each keyword is only submitted once by maintaining a log file.
- Node.js installed on your machine.
- Google Cloud project with Indexing API enabled.
- OAuth 2.0 credentials for your Google Cloud project.
- Access to
keywords.jsoncontaining keywords.
-
Clone the repository:
git clone https://github.com/mughu94/Google-Indexing-API-2024.git cd Google-Indexing-API-2024 -
Install dependencies:
npm install
-
Configure Google Cloud OAuth 2.0 credentials:
- Create OAuth 2.0 credentials in your Google Cloud project.
- Download the
client_secret.jsonfile and place it in the project root directory.
-
Authenticate with Google: The first time you run the script, you'll be prompted to authenticate with Google. Follow the instructions in the terminal to authorize access.
node index.js
-
Subsequent Runs: The script will use the stored token from the first authentication, so you won't need to re-authenticate.
index.js: Main script file.client_secret.json: Google OAuth 2.0 client credentials.token.json: Stored OAuth 2.0 token for subsequent runs.log.txt: Log file to track submitted keywords.
Fetches keywords from keywords.json located at https://raw.githubusercontent.com/mughu94/Google-Indexing-API-2024/main/keywords.json.
Checks if a keyword has already been submitted by looking in the log.txt file.
Creates an OAuth2 client with the given credentials and executes the provided callback function.
Prompts the user to authorize access and stores the retrieved token for future use.
Processes keywords and calls the Google Indexing API to submit them. Logs the success or error of each submission.
The script logs each keyword submission to log.txt with a timestamp and status (success or error).
If an error occurs during the keyword fetching or submission process, it will be logged to log.txt.
This project is licensed under the MIT License - see the LICENSE file for details.