Skip to main content

English | 简体中文

bookstw

Powered by selenium, bookstw is a simple library to interact with Books.com.tw.

Installation

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.

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.

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 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.

Metadata

Release files for bookstw 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bookstw 0.1.1
File Size Uploaded Provenance
bookstw-0.1.1.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bookstw 0.1.1
File Interpreter ABI Platform
bookstw-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / bookstw-0.1.1.tar.gz

Download URL bookstw-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
947ccd15d991e0bb240786360c7aa4d90f3f052553a0f997dd9416e14c0095c0
BLAKE2b-256 checksum
How to use checksums
6b667e6e2f0892acf55a3a1b57ef15567be5e476251a3f4092d9cf843a64dd3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.0 Linux/6.5.0-1016-azure

Release files / bookstw-0.1.1-py3-none-any.whl

Download URL bookstw-0.1.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa008bdde0701e07c9c40d12642fd8b70c87fc7a296c95db804ae94eb307fb74
BLAKE2b-256 checksum
How to use checksums
050336921084acb8b4bc53ac826c3d66b4b797f51f4af61e9cc105debbaec5f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.0 Linux/6.5.0-1016-azure

Security for bookstw 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page