MemeSite

MemeSite is the superclass that defines the interface for all the meme-extraction subclasses. The subclasses should implement caching to improve reading performance.

class meme_get.memesites.MemeSite(url, cache_size=500, maxcache_day=1)[source]

A super class for any sites with respect to memes.

This class should be subclassed. The MemeSite is designed to keep all Memes in a cache file, so that even if the Python process is terminated, the next time we run the save process, we don’t need to re-download all the memes from the Internet. The _meme_pool and _meme_deque store memes, but the users should not view the memes in them as constant, as operations on the object will change the memes inside the pool and deque.

Attributes:
  • _url (str): URL for the website hosting memes
  • _max_tries (int): Max tries for http requests
  • _meme_pool (set): A set containing stored memes
  • _meme_deque (deque): A deque containing stored memes
  • _last_update (datetime object): The time of last download of memes
  • _cache_size (int): Number of memes stored on disk
  • _maxcache_day (int): Max day of keeping the cache on disk
clean_meme_deque()[source]

Empty the meme deque

Returns:None
Return type:NoneType
clean_meme_pool()[source]

Empty the meme pool

Returns:None
Return type:NoneType
get_captions(num_memes)[source]

Return a list of captions.

Returns:A list of strings representing the captions. If captions do not exist, the string will be of None type.
Return type:list
get_meme_num()[source]

Return the number of memes we have.

Returns:An int
Return type:int
get_meme_pool()[source]

Return a set of memes

Returns:A set of Memes
Return type:set
get_memes(num_memes)[source]

Return a list of Memes.

Returns:A list of Meme objects.
Return type:list
get_unique_meme_num()[source]

Return the number of unique memes we have

Returns:An int
Return type:int
get_url()[source]

Return the base url

Returns:A string representing the url to the origin site.abs
Return type:str