GoogleLens


NameGoogleLens JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/AbolDev/GoogleLens
SummaryA library for interacting with the Aparat API
upload_time2024-10-07 15:57:23
maintainerNone
docs_urlNone
authorAbol
requires_python>=3.6
licenseMIT
keywords python library google google-api googlelens-api googlelens-lib google-lib googlelens-python google-python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GoogleLens

GoogleLens is a Python library that allows you to perform image searches using Google Lens. You can upload images via URLs, file paths, or binary data and retrieve visual match results.

## Installation

You can install the library via pip:

```bash
pip install GoogleLens
```

## Features

- Upload images from a URL, file path, or binary data.
- Extract raw text or structured visual match data from the Google Lens response.
- Retrieve the main and similar visual match results, including titles, thumbnails, and page URLs.

## Usage

### Uploading Images and Retrieving Results

#### Example 1: Upload image from URL

```python
from googlelens import GoogleLens

# Initialize GoogleLens instance
lens = GoogleLens()

# Upload image from URL
url = "https://example.com/sample-image.jpg"
result_url = lens.upload_image(url)

# Extract and print visual match results
print("Results from URL search:")
print(result_url.extract_visual_results())
```

#### Example 2: Upload image from file path

```python
from googlelens import GoogleLens

# Initialize GoogleLens instance
lens = GoogleLens()

# Upload image from a file path
file_path = "path/to/sample-image.jpg"
result_file = lens.upload_image(file_path)

# Extract and print visual match results
print("Results from file search:")
print(result_file.extract_visual_results())
```

#### Example 3: Upload image using bytes

```python
from googlelens import GoogleLens

# Initialize GoogleLens instance
lens = GoogleLens()

# Read image as bytes
with open("path/to/sample-image.jpg", "rb") as f:
    image_bytes = f.read()

# Upload image using bytes
result_bytes = lens.upload_image(image_bytes)

# Extract and print visual match results
print("Results from bytes search:")
print(result_bytes.extract_visual_results())
```

### Extracting Raw Text

You can also extract raw text from the Google Lens results, if available:

```python
# Extract raw text from the Google Lens response
raw_text = result_url.extract_raw_text()
print("Raw text extracted from the response:")
print(raw_text)
```

## API Reference

### `GoogleLens`

Main class to interact with Google Lens.

- `upload_image(image_input: Union[str, bytes]) -> GoogleLensResults`
  - Uploads an image to Google Lens and returns the search results.
  - `image_input`: Can be a URL (str), file path (str), or binary data (bytes).
  
### `GoogleLensResults`

Handles the parsing and extraction of useful data from the Google Lens response.

- `extract_visual_results() -> Dict[str, Union[None, Dict[str, str], List[Dict[str, str]]]]`
  - Extracts the visual match results including the main match and a list of similar matches.
  
- `extract_raw_text() -> List[str]`
  - Extracts raw text from the Google Lens response, if available.

## Contributing

Feel free to submit issues or pull requests. Contributions are welcome!

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AbolDev/GoogleLens",
    "name": "GoogleLens",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "python, library, Google, Google-api, GoogleLens-api, GoogleLens-lib, Google-lib, GoogleLens-python, Google-python",
    "author": "Abol",
    "author_email": "abaqry8686@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7a/e6/347c7523ebcc5892401fd2dbf1cbd0d289035f16f9532f3fdf0b9b3e3e57/googlelens-0.1.0.tar.gz",
    "platform": null,
    "description": "# GoogleLens\r\n\r\nGoogleLens is a Python library that allows you to perform image searches using Google Lens. You can upload images via URLs, file paths, or binary data and retrieve visual match results.\r\n\r\n## Installation\r\n\r\nYou can install the library via pip:\r\n\r\n```bash\r\npip install GoogleLens\r\n```\r\n\r\n## Features\r\n\r\n- Upload images from a URL, file path, or binary data.\r\n- Extract raw text or structured visual match data from the Google Lens response.\r\n- Retrieve the main and similar visual match results, including titles, thumbnails, and page URLs.\r\n\r\n## Usage\r\n\r\n### Uploading Images and Retrieving Results\r\n\r\n#### Example 1: Upload image from URL\r\n\r\n```python\r\nfrom googlelens import GoogleLens\r\n\r\n# Initialize GoogleLens instance\r\nlens = GoogleLens()\r\n\r\n# Upload image from URL\r\nurl = \"https://example.com/sample-image.jpg\"\r\nresult_url = lens.upload_image(url)\r\n\r\n# Extract and print visual match results\r\nprint(\"Results from URL search:\")\r\nprint(result_url.extract_visual_results())\r\n```\r\n\r\n#### Example 2: Upload image from file path\r\n\r\n```python\r\nfrom googlelens import GoogleLens\r\n\r\n# Initialize GoogleLens instance\r\nlens = GoogleLens()\r\n\r\n# Upload image from a file path\r\nfile_path = \"path/to/sample-image.jpg\"\r\nresult_file = lens.upload_image(file_path)\r\n\r\n# Extract and print visual match results\r\nprint(\"Results from file search:\")\r\nprint(result_file.extract_visual_results())\r\n```\r\n\r\n#### Example 3: Upload image using bytes\r\n\r\n```python\r\nfrom googlelens import GoogleLens\r\n\r\n# Initialize GoogleLens instance\r\nlens = GoogleLens()\r\n\r\n# Read image as bytes\r\nwith open(\"path/to/sample-image.jpg\", \"rb\") as f:\r\n    image_bytes = f.read()\r\n\r\n# Upload image using bytes\r\nresult_bytes = lens.upload_image(image_bytes)\r\n\r\n# Extract and print visual match results\r\nprint(\"Results from bytes search:\")\r\nprint(result_bytes.extract_visual_results())\r\n```\r\n\r\n### Extracting Raw Text\r\n\r\nYou can also extract raw text from the Google Lens results, if available:\r\n\r\n```python\r\n# Extract raw text from the Google Lens response\r\nraw_text = result_url.extract_raw_text()\r\nprint(\"Raw text extracted from the response:\")\r\nprint(raw_text)\r\n```\r\n\r\n## API Reference\r\n\r\n### `GoogleLens`\r\n\r\nMain class to interact with Google Lens.\r\n\r\n- `upload_image(image_input: Union[str, bytes]) -> GoogleLensResults`\r\n  - Uploads an image to Google Lens and returns the search results.\r\n  - `image_input`: Can be a URL (str), file path (str), or binary data (bytes).\r\n  \r\n### `GoogleLensResults`\r\n\r\nHandles the parsing and extraction of useful data from the Google Lens response.\r\n\r\n- `extract_visual_results() -> Dict[str, Union[None, Dict[str, str], List[Dict[str, str]]]]`\r\n  - Extracts the visual match results including the main match and a list of similar matches.\r\n  \r\n- `extract_raw_text() -> List[str]`\r\n  - Extracts raw text from the Google Lens response, if available.\r\n\r\n## Contributing\r\n\r\nFeel free to submit issues or pull requests. Contributions are welcome!\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for interacting with the Aparat API",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/AbolDev/GoogleLens/issues",
        "Homepage": "https://github.com/AbolDev/GoogleLens",
        "Source Code": "https://github.com/AbolDev/GoogleLens"
    },
    "split_keywords": [
        "python",
        " library",
        " google",
        " google-api",
        " googlelens-api",
        " googlelens-lib",
        " google-lib",
        " googlelens-python",
        " google-python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93b71c5d6b69b86de5d86c9e5e235e829ba0d6a6c6257251c18b51b2d8bb67de",
                "md5": "145875b1ff54fce22476c0de899dc383",
                "sha256": "f0681dac907e10ad805ba2d5bd4ccb4e1df0e3f3943a5d1639b23e497eed33f5"
            },
            "downloads": -1,
            "filename": "GoogleLens-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "145875b1ff54fce22476c0de899dc383",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5936,
            "upload_time": "2024-10-07T15:57:20",
            "upload_time_iso_8601": "2024-10-07T15:57:20.812447Z",
            "url": "https://files.pythonhosted.org/packages/93/b7/1c5d6b69b86de5d86c9e5e235e829ba0d6a6c6257251c18b51b2d8bb67de/GoogleLens-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ae6347c7523ebcc5892401fd2dbf1cbd0d289035f16f9532f3fdf0b9b3e3e57",
                "md5": "5f8c0915f67cae8cba4b298875c3f4ee",
                "sha256": "69c7d9b2a529d326b21b9ca13bdcc5f12de99d07da0c1ff1cb4b5588626a1d4b"
            },
            "downloads": -1,
            "filename": "googlelens-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5f8c0915f67cae8cba4b298875c3f4ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6031,
            "upload_time": "2024-10-07T15:57:23",
            "upload_time_iso_8601": "2024-10-07T15:57:23.045054Z",
            "url": "https://files.pythonhosted.org/packages/7a/e6/347c7523ebcc5892401fd2dbf1cbd0d289035f16f9532f3fdf0b9b3e3e57/googlelens-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-07 15:57:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AbolDev",
    "github_project": "GoogleLens",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "googlelens"
}
        
Elapsed time: 2.49769s