Ejemplo n.º 1
0
from reddit_collect.redditCollector import RedditCollector

# make an instance
reddit_collector = RedditCollector()

# initialize bare minimum connection parameters.
reddit_collector.user_agent = "reddit post collector v0.1 by /u/jonathan_morgan"

# OR reddit_collector.user_agent = "reddit comment collector v0.1 by /u/jonathan_morgan"

# optional, if you need to log in:
#reddit_collector.username = "******"
#reddit_collector.password = "******"

# optional - also can set path to store cookies, if you want to persist them.
reddit_collector.cookie_file_path = "cookies.txt"

# optional - if your version of mysql doesn't support utf8mb4 (unicode
#    characters greater than 3-bytes), set this to true and it will keep all
#    unicode characters 3 bytes and less, turn those that are 4 bytes long
#    into XML entities, so they are preserved, but don't break database.
# set to escape 4-byte Unicode characters (cursed mysql).
reddit_collector.convert_4_byte_unicode_to_entity = True

#============================================================================
# ==> Collect Posts
#============================================================================

# collect latest 10 entries from /r/all, store them in database.
#reddit_collector.collect_posts( 10 )