Skip to content

Instantly share code, notes, and snippets.

Last active Mar 13, 2021
What would you like to do?
pspsps – show catgirls on Linux terminal
#!/usr/bin/env python3
# pspsps – show catgirls on Linux terminal
import os
import sys
import ascii_magic
except ModuleNotFoundError:
sys.stderr.write("Install ascii_magic first nya~\n")
sys.stderr.write("pip3 install ascii_magic")
import random
import urllib.request
import xml.etree.ElementTree as ET
COLUMNS=os.getenv('COLUMNS', default=80)
MAXKITTENS=100 # Safebooru limit
TAGS='catgirl' # nyan
response = urllib.request.urlopen('%s&limit=%s&tags=%s' % (API, MAXKITTENS, TAGS))
# TODO: handle exceptions here
posts = ET.fromstring(
kitten = random.choice(posts.findall('post'))
pic_url = kitten.attrib['file_url']
pic = ascii_magic.from_url(pic_url, columns=COLUMNS)
# TODO: handle exceptions here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment