ngdownloader.py 文件源码

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

项目:national-geographic-wallpaper 作者: atareao 项目源码 文件源码
def get_national_geographic_data():
    # Filename with data: .gallery.<currentYear>-<currentMonth>.json
    today = datetime.today()
    year = str(today.year)
    if today.month < 10:
        month = '0' + str(today.month)
    else:
        month = str(today.month)
    url = URL00 + year + '-' + month + '.json'
    r = requests.get(url)
    if r.status_code == 200:
        data = r.json()
        if 'items' in data:
            current_photo = data['items'][0]
            # TODO: include preferred image size in configuration
            url = current_photo['url'] + current_photo['sizes']['1600']
            return dict(url=url,
                        title=current_photo['title'],
                        caption=current_photo['caption'],
                        credit=current_photo['credit'])
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号