get_json.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:demo-day-vikings 作者: Mester 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号