Skip to content

geoffreyn/CutePetsNYC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CutePetsNYC @CutePetsNYC

This is a bot that retrieves listings from New York City animal shelters and tweets photos and profile links to eligible pets.

Forked from [CutePetsBmore][https://github.com/Ryan-J-Smith/CutePetsBmore]. Inspired by previous work by CutePetsDenver and CutePetsAustin.

The python script assumes that available animals are posted on the Petango service.

Quickstart:

On twitter:

  1. Create the twitter account that will be used to post tweets
  2. Log into this new account and navigate to http://apps.twitter.com
  3. Create a new app with permission to post
  4. Generate credentials (consumer keys and access tokens)

In code:

  1. Configure credentials.py by adding the keys generated by twitter
  2. Install dependencies pip install -r requirements.txt
  3. Modify shelters.py to include desired shelters from Petango (see below)
  4. Tweet a singe pet listing: python tweet_pet.py

Schedule regular tweeting with crontab (Linux):

  1. From the command line, edit the crontab file: crontab -e
  2. Schedule the script to run every hour using a line similar to: 0 * * * * /usr/bin/python /path/to/tweet_pet.py >> /path/to/log.log) 2>&1

Notes:

Extension to other shelters

The shelters.py scrapes the Petango page listing to get the list of shelters dependent on the ZIPCODE and DISTANCE_IN_MILES variables, both of which must be integers typecasted as strings. Shelters may be manually determined and set as SHELTER_IDS if the bool SCRAPE_IDS is set to False.

The tweet_pet.py retrieves a list of animals from each each of the shelters found by shelters.py then tweets an animal at random from this list. As a result, modifying this script to access animals from other shelters is as simple as modifying this dictionary.

Avoidance of duplicate tweets

The script tweet_pet.py attempts to avoid reposting tweets about the same animals. This is done by tracking recent tweets in a buffer file created by the script. The size of the buffer file can be adjusted by changing the value of the NUM_RECENT_TWEETS in tweet_pet.py.

Addtional notes:

  • I intended this to run on a Raspberry Pi running Raspbian. The python script posts a new tweet each time it is called. Regularly scheduled posting is handled by cron.

About

Bot that retrieves listings from Baltimore animal shelters and tweets photos and profile links to eligible pets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%