def main():
"""Method to put it all together"""
db = TinyDB(os.path.join(os.getcwd(), DATABASE_NAME))
for sort_type in ["hot", "new", "top"]:
logger.debug("Fetching url: {}".format(sort_type))
json_data = get_json_from_subreddit(sort_type, 100)
json_list = []
for data in json_data:
for post in data['data']['children']:
if is_post_valid(post):
j = convert_post_to_json(post)
if j is not None:
insert_into_database(db, j)
评论列表
文章目录