bookstw


Namebookstw JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummarySimple tool to interact with books.com.tw
upload_time2024-03-25 07:15:23
maintainerNone
docs_urlNone
authorzyf722
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            **English** | [简体中文](README.zh-CN.md)

# bookstw
Powered by [selenium](https://selenium-python.readthedocs.io/), `bookstw` is a simple library to interact with Books.com.tw.

## Installation
```bash
pip install bookstw
```

## Quick Start
Let's get started with a simple example that logs in to Books.com.tw and signs in daily.

> [!NOTE]
>
> For now it is the only feature provided by `bookstw`.

```python
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options

from bookstw import BooksTWRunner
from bookstw.ocr.baidu import BaiduHandwritingOCR

if __name__ == "__main__":
    baidu_ocr = BaiduHandwritingOCR(
        proxy={"http": "", "https": ""},
        api_key="<YOUR_API_KEY>",
        secret_key="<YOUR_SECRET>"
    )
    options = Options()
    options.add_argument("--disable-gpu")
    options.add_argument("--disable-logging")
    options.add_argument("--log-level=3")
    options.add_argument("--headless")
    options.add_experimental_option("excludeSwitches", ["enable-logging"])
    chrome = Chrome(options)

    runner = BooksTWRunner(ocr=baidu_ocr, webdriver=chrome)
    runner.login("<YOUR_USERNAME>", "<YOUR_PASSWORD>")
    runner.daily_sign_in()
```

The above code snippet demonstrates how to sign in daily with `bookstw`.

The `BaiduHandwritingOCR` is used to solve the captcha.  Currently, it is the only OCR provider supported by `bookstw`. However, you can implement your own OCR provider by inheriting the [`BaseOCR` class](./src/bookstw/ocr/__init__.py).

## Github Actions
Fork this repository and create the following secrets in your repository:
- `BAIDU_API_KEY`
- `BAIDU_SECRET_KEY`
- `BOOKS_TW_USERNAME`
- `BOOKS_TW_PASSWORD`

Check the [workflow file](.github/workflows/auto-signin.yml) for more details.

## API Reference
### `bookstw.BooksTWRunner`
#### `bookstw.BooksTWRunner.__init__(ocr: BaseOCR, webdriver: WebDriver)`
Creates a new `BooksTWRunner` instance.

- `ocr`: The OCR provider used to solve the captcha.
- `webdriver`: The WebDriver used to interact with Books.com.tw.

#### `bookstw.BooksTWRunner.login(self, username: str, password: str, ocr_retry: int = 3, retry_delay: int = 5) -> None`
Login to books.com.tw.

- `username`: Username.
- `password`: Password.
- `ocr_retry`: Number of retries for OCR.
- `retry_delay`: Delay between retries in seconds.

#### `bookstw.BooksTWRunner.daily_sign_in(self) -> None`
Sign in daily.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bookstw",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "zyf722",
    "author_email": "MaxMixAlex@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6b/66/7e6e2f0892acf55a3a1b57ef15567be5e476251a3f4092d9cf843a64dd3a/bookstw-0.1.1.tar.gz",
    "platform": null,
    "description": "**English** | [\u7b80\u4f53\u4e2d\u6587](README.zh-CN.md)\n\n# bookstw\nPowered by [selenium](https://selenium-python.readthedocs.io/), `bookstw` is a simple library to interact with Books.com.tw.\n\n## Installation\n```bash\npip install bookstw\n```\n\n## Quick Start\nLet's get started with a simple example that logs in to Books.com.tw and signs in daily.\n\n> [!NOTE]\n>\n> For now it is the only feature provided by `bookstw`.\n\n```python\nfrom selenium.webdriver import Chrome\nfrom selenium.webdriver.chrome.options import Options\n\nfrom bookstw import BooksTWRunner\nfrom bookstw.ocr.baidu import BaiduHandwritingOCR\n\nif __name__ == \"__main__\":\n    baidu_ocr = BaiduHandwritingOCR(\n        proxy={\"http\": \"\", \"https\": \"\"},\n        api_key=\"<YOUR_API_KEY>\",\n        secret_key=\"<YOUR_SECRET>\"\n    )\n    options = Options()\n    options.add_argument(\"--disable-gpu\")\n    options.add_argument(\"--disable-logging\")\n    options.add_argument(\"--log-level=3\")\n    options.add_argument(\"--headless\")\n    options.add_experimental_option(\"excludeSwitches\", [\"enable-logging\"])\n    chrome = Chrome(options)\n\n    runner = BooksTWRunner(ocr=baidu_ocr, webdriver=chrome)\n    runner.login(\"<YOUR_USERNAME>\", \"<YOUR_PASSWORD>\")\n    runner.daily_sign_in()\n```\n\nThe above code snippet demonstrates how to sign in daily with `bookstw`.\n\nThe `BaiduHandwritingOCR` is used to solve the captcha.  Currently, it is the only OCR provider supported by `bookstw`. However, you can implement your own OCR provider by inheriting the [`BaseOCR` class](./src/bookstw/ocr/__init__.py).\n\n## Github Actions\nFork this repository and create the following secrets in your repository:\n- `BAIDU_API_KEY`\n- `BAIDU_SECRET_KEY`\n- `BOOKS_TW_USERNAME`\n- `BOOKS_TW_PASSWORD`\n\nCheck the [workflow file](.github/workflows/auto-signin.yml) for more details.\n\n## API Reference\n### `bookstw.BooksTWRunner`\n#### `bookstw.BooksTWRunner.__init__(ocr: BaseOCR, webdriver: WebDriver)`\nCreates a new `BooksTWRunner` instance.\n\n- `ocr`: The OCR provider used to solve the captcha.\n- `webdriver`: The WebDriver used to interact with Books.com.tw.\n\n#### `bookstw.BooksTWRunner.login(self, username: str, password: str, ocr_retry: int = 3, retry_delay: int = 5) -> None`\nLogin to books.com.tw.\n\n- `username`: Username.\n- `password`: Password.\n- `ocr_retry`: Number of retries for OCR.\n- `retry_delay`: Delay between retries in seconds.\n\n#### `bookstw.BooksTWRunner.daily_sign_in(self) -> None`\nSign in daily.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple tool to interact with books.com.tw",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "050336921084acb8b4bc53ac826c3d66b4b797f51f4af61e9cc105debbaec5f2",
                "md5": "01fac9032216494014b20f8080bd0087",
                "sha256": "fa008bdde0701e07c9c40d12642fd8b70c87fc7a296c95db804ae94eb307fb74"
            },
            "downloads": -1,
            "filename": "bookstw-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "01fac9032216494014b20f8080bd0087",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 5925,
            "upload_time": "2024-03-25T07:15:22",
            "upload_time_iso_8601": "2024-03-25T07:15:22.153059Z",
            "url": "https://files.pythonhosted.org/packages/05/03/36921084acb8b4bc53ac826c3d66b4b797f51f4af61e9cc105debbaec5f2/bookstw-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b667e6e2f0892acf55a3a1b57ef15567be5e476251a3f4092d9cf843a64dd3a",
                "md5": "8208bae173d70c0d1b0a5638675f2a5a",
                "sha256": "947ccd15d991e0bb240786360c7aa4d90f3f052553a0f997dd9416e14c0095c0"
            },
            "downloads": -1,
            "filename": "bookstw-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8208bae173d70c0d1b0a5638675f2a5a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 4865,
            "upload_time": "2024-03-25T07:15:23",
            "upload_time_iso_8601": "2024-03-25T07:15:23.651193Z",
            "url": "https://files.pythonhosted.org/packages/6b/66/7e6e2f0892acf55a3a1b57ef15567be5e476251a3f4092d9cf843a64dd3a/bookstw-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 07:15:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bookstw"
}
        
Elapsed time: 0.22331s