Skip to main content

Open Source Google SERP API

Project description

GSERP API

Overview

The GSERP API is an open-source project designed to perform search queries on Google and return organic search results. It leverages the requests-ip-rotator to handle IP rotation, ensuring that requests are made from different IP addresses to avoid being blocked by Google. The API is built using Python and provides a simple interface for querying and retrieving search results.

Features

  • IP Rotation: Utilizes requests-ip-rotator to rotate IP addresses for each request.
  • Customizable Search: Allows specifying search parameters such as country, language, location, and fields to retrieve.
  • Field Selection: Users can choose which fields to include in the search results, such as title, link, snippet, etc.
  • Error Handling: Provides detailed error messages for invalid field selections and connection issues.

Installation

pip install gserp-api

or from source:

git clone git@github.com:rushout09/gserp-api.git
cd gserp-api
python3 -m venv venv
source venv/bin/activate
pip install -r requriements.txt

Usage

import os
from requests_ip_rotator import ApiGateway
from gserp_api import search

# Set AWS credentials
aws_access_key_id = os.getenv('AWS_ACCESS_KEY_ID')
aws_secret_access_key = os.getenv('AWS_SECRET_ACCESS_KEY')

# Create and start an API Gateway
gateway = ApiGateway("https://www.google.com", access_key_id=aws_access_key_id, secret_access_key=aws_secret_access_key)
gateway.start()

try:
    # Perform a search
    query = "OpenAI GPT-4"
    fields = ["title", "link", "snippet"]
    results = search(gateway, query, *fields, country="US", lang="en")
    print(results)

finally:
    # Shut down the API Gateway
    gateway.shutdown()

How to get AWS Credentials

To obtain AWS credentials, you need to create an IAM user in the AWS Management Console and assign the necessary permissions. Here’s a step-by-step guide:

How to Get AWS Credentials

  1. Sign in to AWS Management Console: Go to the AWS Management Console. Sign in with your AWS account credentials.

  2. Navigate to IAM (Identity and Access Management): In the AWS Management Console, search for "IAM" in the services search bar and select it.

  3. Create a New IAM User: In the IAM dashboard, click on "Users" in the left sidebar. Click the "Add user" button. Enter a username for the new user. Select the "Programmatic access" checkbox to generate an access key ID and secret access key.

  4. Set Permissions: Choose how you want to set permissions for the user. You can either: Attach existing policies directly (e.g., AmazonS3FullAccess for S3 access). Add the user to a group with the necessary permissions. Copy permissions from an existing user. Attach custom policies if needed.

  5. Review and Create User: Review the user details and permissions. Click "Create user".

  6. Download Credentials: After the user is created, you will see the access key ID and secret access key. Download the .csv file containing these credentials or copy them to a secure location. You will not be able to view the secret access key again.

  7. Set Environment Variables: On your local machine, set the AWS credentials as environment variables: your_secret_access_key

  8. Use Credentials in Your Application: Your application can now use these environment variables to authenticate with AWS services.

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

gserp_api-0.1.7.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

gserp_api-0.1.7-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file gserp_api-0.1.7.tar.gz.

File metadata

  • Download URL: gserp_api-0.1.7.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gserp_api-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9d2fbaa477461ace8fef71792ddb2efd507fd12f76e6cb24b29ca8a159d3e218
MD5 b056ebc7f0477e30cffdacaa82cbb5fa
BLAKE2b-256 9d7d8d67b6b26baf4214005ef5f1f649c3fe0b58f93763d47a83d5d741b073db

See more details on using hashes here.

File details

Details for the file gserp_api-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: gserp_api-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gserp_api-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 64f7a9928814b6934c339138150deb6093ef7744678d915c94984e7c96d21c6f
MD5 2d1e16ed232c2038355153669a513b39
BLAKE2b-256 26562c05fe0a56893f24ffdc44e2a47396a648b8b1569b73f2b63b6676b1f072

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