Metadata-Version: 2.2
Name: imgscraper
Version: 0.3.0
Summary: Scans web pages for images
Author-email: Dawid Szaniawski <webluduspl@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Dawid Szaniawski
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Source, https://github.com/dawid-szaniawski/imgscraper
Keywords: api,automation,json,web
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Classifier: Topic :: File Formats :: JSON
Classifier: Topic :: File Formats :: JSON :: JSON Schema
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: bepatient==0.17.0
Requires-Dist: requests>=2.28.1
Requires-Dist: beautifulsoup4~=4.12.3
Provides-Extra: dev
Requires-Dist: black~=23.10.1; extra == "dev"
Requires-Dist: flake8~=6.1.0; extra == "dev"
Requires-Dist: isort~=5.12.0; extra == "dev"
Requires-Dist: mypy~=1.6.1; extra == "dev"
Requires-Dist: pylint<=3.0.2; extra == "dev"
Requires-Dist: pylint-pytest~=1.1.3; extra == "dev"
Requires-Dist: pytest~=7.4.2; extra == "dev"
Requires-Dist: pytest-cov~=4.1.0; extra == "dev"
Requires-Dist: pytest-mock~=3.12.0; extra == "dev"
Requires-Dist: responses~=0.25.6; extra == "dev"
Requires-Dist: ruff~=0.1.2; extra == "dev"
Requires-Dist: tox~=4.11.3; extra == "dev"
Requires-Dist: twine~=4.0.2; extra == "dev"

[![Tests](https://github.com/dawid-szaniawski/imgscraper/actions/workflows/tox.yml/badge.svg)](https://github.com/dawid-szaniawski/imgscraper/actions/workflows/tox.yml)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/imgscraper)](https://pypi.org/project/imgscraper/)
[![PyPI](https://img.shields.io/pypi/v/imgscraper)](https://pypi.org/project/imgscraper/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/dawid-szaniawski/imgscraper/blob/master/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![codecov](https://codecov.io/github/dawid-szaniawski/imgscraper/branch/master/graph/badge.svg?token=hY7Nb5jGgi)](https://codecov.io/github/dawid-szaniawski/imgscraper)
[![CodeFactor](https://www.codefactor.io/repository/github/dawid-szaniawski/imgscraper/badge)](https://www.codefactor.io/repository/github/dawid-szaniawski/imgscraper)

# imgscraper: yet another web scraper

imgscraper is a simple library that allows you to retrieve image information from meme sites.

## Installation

To install _imgscraper_, you can use pip:

```bash
pip install imgscraper
```

_ImgScraper_ supports Python 3.10+


## Usage

```python
from imgscraper.scraper_constructor import create_scraper

img_scraper = create_scraper(
    website_url="https://imagocms.webludus.pl/",
    container_class="image-holder",
    pagination_class="pagination"
)

img_scraper.start_sync()

print(img_scraper.synchronization_data)
```

Output:

```python
[
    Image(
        source="https://imagocms.webludus.pl/images/01/",
        url_address="https://imagocms.webludus.pl/img/01.jpg",
        title="String"
    ),
    Image(
        source="https://imagocms.webludus.pl/images/02/",
        url_address="https://imagocms.webludus.pl/img/02.jpg",
        title="String"
    )
]
```

## Pages to scan and scraper

The user can specify how many subpages should be scraped and what tool the application should use.

```python
from imgscraper.scraper_constructor import create_scraper

img_scraper = create_scraper(
    website_url="https://imagocms.webludus.pl/",
    container_class="image-holder",
    pagination_class="pagination",
    pages_to_scan=1,
    scraper="bs4"
)
```

## Last sync data

When starting the synchronization process, the user can provide data from the last synchronization (img.src).
If the application encounters a provided image, the process is terminated. All previously synced images are available.

```python
scraper.start_sync(
    (
        "https://imagocms.webludus.pl/img/01.jpg",
        "https://imagocms.webludus.pl/img/02.jpg",
    )
)
```

## Image Object

The Image object provides the ``.as_dict()`` method to turn it into a dictionary.

```python
img = Image(
    source="https://imagocms.webludus.pl/images/01/",
    url_address="https://imagocms.webludus.pl/img/01.jpg",
    title="String"
).as_dict()
```

Output:

```python
img = {
    "source": "https://imagocms.webludus.pl/images/01/",
    "url_address": "https://imagocms.webludus.pl/img/01.jpg",
    "title": "String"
}
```
