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
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_memes
(num_memes)[source]¶ Return a list of Memes.
Returns: A list of Meme objects. Return type: list