ngdownloader.py 文件源码

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

项目:national-geographic-wallpaper 作者: atareao 项目源码 文件源码
def set_nasa_wallpaper():
    st = datetime.fromtimestamp(time.time()).strftime('%y%m%d')
    url = URL07.format(st)
    r = requests.get(url)
    if r.status_code == 200:
        try:
            parser = etree.HTMLParser(recover=True)
            html = etree.HTML(r.content, parser)
            images = html.iter('img')
            if images is not None:
                images = list(images)
                if len(images) > 0:
                    image_url = images[0].getparent().attrib['href']
                    image_url = 'https://apod.nasa.gov/' + image_url
                    if download(image_url) is True:
                        set_background(comun.POTD)
        except Exception as e:
            print(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号