Skip to main content

comics


GoComics API wrapper

Python 3.8+ pypiv Licence tests

Installation

pip install comics

Quick start

Find and download the Calvin and Hobbes comic strip published on January 2, 1990:

import comics

ch = comics.search("calvinandhobbes", date="1990-01-02")
ch.download("calvinandhobbes.png")

Find comics

Available comics can be found using the directory class:

import comics

# List available comics - total of 401
comics.directory.listall()
# >>> ("1-and-done", "9-chickweed-lane-classics", "9chickweedlane", "9to5", ... )

# Find endpoints for Calvin and Hobbes
comics.directory.search("Calvin and Hobbes")
# >>> ("calvinandhobbes", "calvinandhobbesenespanol")

First, pass the desired endpoint to comics.search. For example, to search for Calvin and Hobbes comics in english use comics.search("calvinandhobbes"); for spanish, use comics.search("calvinandhobbesenespanol").

Search and download comics

Then, search for a comic strip by passing date into search():

import comics

# Get a Calvin and Hobbes comic strip by date
ch = comics.search("calvinandhobbes", date="2013-05-13")  # Also accepts datetime.date or datetime object

# Get a random Calvin and Hobbes comic strip
random_ch = comics.search("calvinandhobbes", date="random")

Finally, show, download, or stream the comic strip:

# Show comic strip - opens in Jupyter notebook or default image viewer application
ch.show()

# Download comic strip - defaults to {endpoint}.png if an export path is not provided
# E.g., a Calvin and Hobbes comic strip will be exported as "calvinandhobbes.png" in the current working directory
ch.download()

# Stream comic strip - useful if custom image content manipulation is desired
ch.stream()

Retry logic

If a comic strip fails to load due to CDN delays or missing image data, a retry mechanism is built into download(), show(), and stream(). You can control this behavior via:

  • retries: number of attempts before failing (default = 5)
  • base_delay: exponential backoff seed time in seconds (default = 0.5)

This improves reliability when fetching newly released strips or handling transient issues.

Attempt Wait Before Attempt (sec) Cumulative Time (sec)
1 0.0 0.0
2 0.5 0.5
3 1.0 1.5
4 2.0 3.5
5 4.0 7.5
6 8.0 15.5

Retry behavior can be customized per call:

# Try 3 times total with shorter delay
ch.download(retries=2, base_delay=0.25)

Attributes

An instantiated search class will have the following public attributes:

import comics

garfield = comics.search("garfield")
garfield.endpoint
# >>> "garfield"
garfield.title
# >>> "Garfield"
garfield.start_date
# >>> "1978-06-19"

An instantiated search class with date will have the following public attributes:

import comics

garfield = comics.search("garfield", date="2000-08-20")
garfield.endpoint
# >>> "garfield"
garfield.title
# >>> "Garfield"
garfield.date
# >>> "2000-08-20"
garfield.url
# >>> "https://www.gocomics.com/garfield/2000/08/20"
garfield.image_url
# >>> "https://assets.amuniversal.com/6694c52099bd01365606005056a9545d"

Exceptions

An exception will be thrown if the queried date is unregistered or before the comic's origin date:

import comics

try:
    peanuts = comics.search("peanuts", date="1900-01-01")
    peanuts.download()
except comics.exceptions.InvalidDateError:
    print("Whoops, an invalid date was queried.")

An exception will be thrown if the queried endpoint is unregistered:

import comics

try:
    invalid_comic = comics.search("invalid_endpoint", date="2000-01-01")
    invalid_comic.download()
except comics.exceptions.InvalidEndpointError:
    print("Whoops, an invalid endpoint was queried.")

An exception will be thrown if GoComics' CDN rejects the request (HTTP 403, HTTP 429 rate limiting, or an anti-bot challenge that never resolves). This is not retried, since it depends on your client and network rather than the date:

import comics

try:
    garfield = comics.search("garfield", date="2020-05-05")
    garfield.download()
except comics.exceptions.ComicsBlockedError:
    print("GoComics rejected this request. Wait a while or try a different network.")

An exception will be thrown if Playwright fails to fetch a comic (e.g., browser not installed or page error):

import comics

try:
    garfield = comics.search("garfield", date="2020-05-05", force_playwright=True)
    garfield.download()
except comics.exceptions.ComicsPlaywrightError:
    print("Playwright failed to fetch the page. Check your Playwright installation.")

Contribute

Support

If you are having issues or would like to propose a new feature, please use the issues tracker.

License

This project is licensed under the MIT license.

Metadata

Release files for comics 0.10.0

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

Source distribution (sdist)

Source distribution for comics 0.10.0
File Size Uploaded Provenance Actions
comics-0.10.0.tar.gz 28.9 kB Without provenance Details for comics-0.10.0.tar.gz

Built distribution (wheel)

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

Total release size: 50.1 kB

Release files / comics-0.10.0.tar.gz

Download URL comics-0.10.0.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e95081461e15e7923c60a2f0e895948102d68a36afb0a8e7b6389cba2b0a7a4f
BLAKE2b-256 checksum
How to use checksums
787e479e3253b75933559e55c5bacbc9bcb93c450a6818a1ec68e87597aa2c0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / comics-0.10.0-py3-none-any.whl

Download URL comics-0.10.0-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67047f72afbd61399f3a2d88afa2f4f3c267128ca9c663adf3f638e682568b4d
BLAKE2b-256 checksum
How to use checksums
73d02abc22e05d91aa8719084a64e2c4bed5c5dcb00728dd93d80a0672f0052e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for comics 0.10.0

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