Skip to main content

Cartoonista - A python cartoon library

A library to get a random cartoon image url from ~20000 cartoons. It also contains the scrapers for many cartoon websites.

🎉 😆 🤦‍♂️ A product of the finest german overengineering to solve a non existing problem with a complicated solution. 🤦‍♂️ 😆 🎉

Sites

English:

German:

This lib includes all scrapers for these sites, but it ships with all data, so these are only needed for manual updating.

Install

pip install cartoonista

Examples / Documentation

from cartoons import Cartoons

Cartoons.get_random_cartoon(
    include=["xkcd_com", "ruthe_de"],  # optional
    exclude=["loadingartist_com", "commitstrip_com"],  # optional
    languages=["en"],  # optional
    exclude_tags=["offensive"],  # optional
    weighted=False  # optional
)

This is the main function to get a random cartoon. There are optional filter parameters:

  • cartoonists: Get only from these cartoonists. You can get the names and all infos with Cartoons.get_all_cartoonists()
  • language: Get only in this languages. There are currently only "en" and "de" cartoons.
  • exclude_tags: Exclude cartoonists by tags. Possible values: "offensive", "nsfw"
  • weighted: Default is to give cartoonists a weight by the amount of there cartoons, to prevent double cartoons for cartoonists with small amounts. This can be disabled, to randomize even over all cartoonists. The cartoons have to match all filters.

It returns something like this:

{
    'img': 'https://imgs.xkcd.com/comics/standard_model_changes.png', 
    'title': 'Standard Model Changes', 
    'txt': "Bugs are spin 1/2 particles, unless it's particularly windy.", 
    'credits': 'Randall Munroe', 
    'website': 'https://xkcd.com',
    'tags': []
}

Title/txt could be placed over/under the image and it would be fair to give credit and link to website.

Manual updating

Manual updating isn't strictly needed, cause the lib ships with all data, but it's possible.

Install the requirements with pip install pip install cartoonista[scraping] or manually install requests and beautifulsoup4.

Run the scrape.py from the repo (that gives you some logging output) or start scraping by running python -c "exec(\"from cartoons import Cartoons\nCartoons.start_scraping()\")". It's also possible to update only some cartoonist with Cartoons.start_scraping(cartoonists=["islieb.de", "xkcd.com"]).

Metadata

Release files for cartoonista 0.5.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 cartoonista 0.5.1
File Size Uploaded Provenance Actions
cartoonista-0.5.1.tar.gz 357.0 kB Without provenance Details for cartoonista-0.5.1.tar.gz

Release files / cartoonista-0.5.1.tar.gz

Download URL cartoonista-0.5.1.tar.gz
Size 357.0 kB
Tags Source
SHA-256 checksum
How to use checksums
40eff52702237171d6661c7473ba8fe365cb666b8cc04e58c835958faf10994e
BLAKE2b-256 checksum
How to use checksums
f1ae819af5bf34e7b5c3de8e1da0bf8e8e9978bb9f14bb9c2f5957100969dbb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Security for cartoonista 0.5.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.

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