If len ( seen_statuses ) > 20 : seen_statuses. Seen_statuses = status # dump old statuses that can't appear again id not in seen_statuses : # store the statuses we use home_timeline ( tweet_mode = 'extended' ) for status in public_tweets : # we're interested in statuses we haven't seen before Seen_statuses = OrderedDict () while True : public_tweets = api. API ( auth ) # we use an ordered dictionary so we can remove old tweets Import tweepy from emoji import demojize from time import sleep from collections import OrderedDict import config import posprint auth = tweepy. local versus live production deployment). This can be safer (it avoids keys accidentally being pushed to GitHub) and lets our application use different keys in different environments (e.g. A better way of managing keys is for your application to access them at runtime through environment values. posprint.py - for calling the receipt printer.poller.py - for polling Twitter's API via Tweepy, and converting tweets to text.In order to use Tweepy, we need to create an application on Twitter's Developer platform to get the keys and tokens we need to authenticate. Tweepy is a Python library for accessing the Twitter API - it has good documentation and community support. Twitter has a powerful API but it's a little cryptic at first glance. The included demo program solved all of my printing problems. It shows how to write to the USB port directly (a tactic I previously tried and failed). I was stuck until I found vpatron/usb_receipt_printer - a guide that walks through setting the device up on a Raspberry Pi. I couldn't get the drivers to work on Linux, MacOS, or Windows. It's sold by a few different brands under different names. A POS58 USB Thermal Receipt Printer also known as a ZJ-5890K. ![]() ![]() ![]() I was gifted a receipt printer for Christmas to use with my Raspberry Pi. Screens tend to keep me awake in the evening so I wondered if I could print out my Twitter home timeline, live, as I read a book in the evening.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |