py-searchconsole


Namepy-searchconsole JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/Rahulkatoch99/py_searchconsole
SummaryA Python wrapper for the Google Search Console API
upload_time2023-05-05 06:12:35
maintainer
docs_urlNone
authorRahul Katoch
requires_python>=3.6
license
keywords search console api google seo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            searchconsole - Python Library for Google Search Console API

# Introduction

searchconsole is a Python library that provides an easy-to-use interface for working with the Google Search Console API. With this library, you can fetch data from your Search Console account and use it to analyze your website's performance in search results.

# Getting Started

Before you can use the searchconsole library, you need to generate a credentials.json file that will allow you to authenticate with the Google Search Console API. To generate this file, you can use the Credential class provided by the library.
```python
from searchconsole.credential import Credential

client_id = "kjahfdnjkeahfnulkjbn38294u2389"
client_secret = "32u4393kjbjjk3b4bk331094i3jb"

# create the credentials.json file in your home directory

Credential(client_id=client_id, client_secret=client_secret)

# they will send you a new tab where you can allow the permission and get the key

# Enter your Authorization code here:-

```
 After enter the Authorization you will get the credenial.json then after comment the Credential(client_id=client_id, client_secret=client_secret)
 
 

This will create a credentials.json file in your home directory that you can use to authenticate with the API.

# Fetching Data

Once you have generated your credentials.json file, you can use the searchconsole library to fetch data from your Search Console account. Here is an example of how to fetch search analytics data for a given domain:
```python
from searchconsole import SearchConsole

domain = "example.com"
start_date = "2022-01-01"
end_date = "2022-01-31"

authenticate with the API using credentials.json

auth_response = SearchConsole(domain, credentials='credentials.json')

# print the data

# print(auth_response)

report_dict = []
for i in auth_response['rows']:
    auth_data = i
    new_dict = {
        "query": auth_data["keys"][0],
        "page": auth_data["keys"][1],
        "country": auth_data["keys"][2],
        "device": auth_data["keys"][3],
        "date": auth_data["keys"][4],
        "clicks": auth_data["clicks"],
        "impressions": auth_data["impressions"],
        "ctr": auth_data["ctr"],
        "position": auth_data["position"]
    }
    report_dict.append(new_dict)
print(report_dict)

```

# Output:


["query", "page", "country", "device", "date","impression","clicks","position","ctr"]
```python
{
"query":"console",
"country":"ind",
"page":"www.example.com",
"device":"Desktop",
"date":"2023-02-13",
"impression":"23",
"clicks":"23",
"position":"2",
"ctr":"2",
}

```

# Requirements

The following dependencies are required to use the searchconsole library:

apiclient
oauth2client
google-api-python-client
httplib2

You can add these requirements to a file called requirements.txt in the root directory of your library, with each requirement on a new line. This will make it easy for users to install all necessary dependencies by running pip install -r requirements.txt.

# Unit Testing

The searchconsole library comes with a large and growing set of unit tests to ensure its functionality is working correctly. These unit tests can be found in the tests directory of the library. By running the tests, you can ensure that the library is functioning correctly and catch any errors that may arise.

# Conclusion

With the searchconsole library, it is easy to fetch data from your Google Search Console account and use it to analyze your website's performance in search results. By following the steps outlined in this document, you can quickly get started with the library and begin using it to improve your website's search performance.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Rahulkatoch99/py_searchconsole",
    "name": "py-searchconsole",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "search console api google seo",
    "author": "Rahul Katoch",
    "author_email": "rahulkatoch99@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/99/d7/dad9cf317d5e37bd13d2317f5f2b8988a7022c56904cc2c6afd4e11ad5d9/py_searchconsole-1.0.1.tar.gz",
    "platform": null,
    "description": "searchconsole - Python Library for Google Search Console API\n\n# Introduction\n\nsearchconsole is a Python library that provides an easy-to-use interface for working with the Google Search Console API. With this library, you can fetch data from your Search Console account and use it to analyze your website's performance in search results.\n\n# Getting Started\n\nBefore you can use the searchconsole library, you need to generate a credentials.json file that will allow you to authenticate with the Google Search Console API. To generate this file, you can use the Credential class provided by the library.\n```python\nfrom searchconsole.credential import Credential\n\nclient_id = \"kjahfdnjkeahfnulkjbn38294u2389\"\nclient_secret = \"32u4393kjbjjk3b4bk331094i3jb\"\n\n# create the credentials.json file in your home directory\n\nCredential(client_id=client_id, client_secret=client_secret)\n\n# they will send you a new tab where you can allow the permission and get the key\n\n# Enter your Authorization code here:-\n\n```\n After enter the Authorization you will get the credenial.json then after comment the Credential(client_id=client_id, client_secret=client_secret)\n \n \n\nThis will create a credentials.json file in your home directory that you can use to authenticate with the API.\n\n# Fetching Data\n\nOnce you have generated your credentials.json file, you can use the searchconsole library to fetch data from your Search Console account. Here is an example of how to fetch search analytics data for a given domain:\n```python\nfrom searchconsole import SearchConsole\n\ndomain = \"example.com\"\nstart_date = \"2022-01-01\"\nend_date = \"2022-01-31\"\n\nauthenticate with the API using credentials.json\n\nauth_response = SearchConsole(domain, credentials='credentials.json')\n\n# print the data\n\n# print(auth_response)\n\nreport_dict = []\nfor i in auth_response['rows']:\n    auth_data = i\n    new_dict = {\n        \"query\": auth_data[\"keys\"][0],\n        \"page\": auth_data[\"keys\"][1],\n        \"country\": auth_data[\"keys\"][2],\n        \"device\": auth_data[\"keys\"][3],\n        \"date\": auth_data[\"keys\"][4],\n        \"clicks\": auth_data[\"clicks\"],\n        \"impressions\": auth_data[\"impressions\"],\n        \"ctr\": auth_data[\"ctr\"],\n        \"position\": auth_data[\"position\"]\n    }\n    report_dict.append(new_dict)\nprint(report_dict)\n\n```\n\n# Output:\n\n\n[\"query\", \"page\", \"country\", \"device\", \"date\",\"impression\",\"clicks\",\"position\",\"ctr\"]\n```python\n{\n\"query\":\"console\",\n\"country\":\"ind\",\n\"page\":\"www.example.com\",\n\"device\":\"Desktop\",\n\"date\":\"2023-02-13\",\n\"impression\":\"23\",\n\"clicks\":\"23\",\n\"position\":\"2\",\n\"ctr\":\"2\",\n}\n\n```\n\n# Requirements\n\nThe following dependencies are required to use the searchconsole library:\n\napiclient\noauth2client\ngoogle-api-python-client\nhttplib2\n\nYou can add these requirements to a file called requirements.txt in the root directory of your library, with each requirement on a new line. This will make it easy for users to install all necessary dependencies by running pip install -r requirements.txt.\n\n# Unit Testing\n\nThe searchconsole library comes with a large and growing set of unit tests to ensure its functionality is working correctly. These unit tests can be found in the tests directory of the library. By running the tests, you can ensure that the library is functioning correctly and catch any errors that may arise.\n\n# Conclusion\n\nWith the searchconsole library, it is easy to fetch data from your Google Search Console account and use it to analyze your website's performance in search results. By following the steps outlined in this document, you can quickly get started with the library and begin using it to improve your website's search performance.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python wrapper for the Google Search Console API",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/Rahulkatoch99/py_searchconsole"
    },
    "split_keywords": [
        "search",
        "console",
        "api",
        "google",
        "seo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f019c2e040005f541340084600ce5307f97da37ad0ee7003f77623e3d5d85b24",
                "md5": "9403b500c8aa8ba08f7cb576fa313927",
                "sha256": "d8befffa524b18d9155661615e1e1bb2833a871c232f3955d8b67dea09c51631"
            },
            "downloads": -1,
            "filename": "py_searchconsole-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9403b500c8aa8ba08f7cb576fa313927",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 2684,
            "upload_time": "2023-05-05T06:12:32",
            "upload_time_iso_8601": "2023-05-05T06:12:32.699463Z",
            "url": "https://files.pythonhosted.org/packages/f0/19/c2e040005f541340084600ce5307f97da37ad0ee7003f77623e3d5d85b24/py_searchconsole-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99d7dad9cf317d5e37bd13d2317f5f2b8988a7022c56904cc2c6afd4e11ad5d9",
                "md5": "82b2a0891667900d4db1b8516d5e2078",
                "sha256": "62976fe5ab3207c7408699d81699a9fc5b4b6ab11b8b6c75237f23d1fc4dd498"
            },
            "downloads": -1,
            "filename": "py_searchconsole-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "82b2a0891667900d4db1b8516d5e2078",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 2805,
            "upload_time": "2023-05-05T06:12:35",
            "upload_time_iso_8601": "2023-05-05T06:12:35.009842Z",
            "url": "https://files.pythonhosted.org/packages/99/d7/dad9cf317d5e37bd13d2317f5f2b8988a7022c56904cc2c6afd4e11ad5d9/py_searchconsole-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-05 06:12:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Rahulkatoch99",
    "github_project": "py_searchconsole",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "py-searchconsole"
}
        
Elapsed time: 0.09938s