美文网首页
python发送新库提醒到手机

python发送新库提醒到手机

作者: Oneshot_fea8 | 来源:发表于2019-01-12 16:09 被阅读0次
    # https://api.github.com/search/repositories?q=topic:crawler+language:python+created:2018-02-08
    # https://api.pushover.net/1/messages.json?token=xx&user=xx&message=xx
    
    # get_info_list -- push_it
    
    from datetime import datetime
    import requests
    
    
    def get_info_list():
        api = 'https://api.github.com/search/repositories?q='
        query = 'topic:crawler+language:python+'
        when = 'created:' + str(datetime.now()).split()[0]
        full_url = api + query + when
        print(full_url)
        r = requests.get(full_url)
        return r.json()['items']
    
    
    def make_message(repo_info):
        title = repo_info['name']
        url = repo_info['html_url']
        message = repo_info['description']
        token = 'xxx'  # 这里需要换成你的 token
        user = 'xxx'  # 这里需要换成你的 pushover user id
        api = 'https://api.pushover.net/1/messages.json?'
        template = 'token={token}&user={user}&message={msg}&title={t}&url={url}'
        query = template.format(
            token=token,
            user=user,
            msg=message,
            t=title,
            url=url
        )
        full_url = api + query
        return full_url
    
    
    def push_it(message):
        requests.post(message)
        print('Done')
    
    
    info_list = get_info_list()
    for info in info_list:
        message = make_message(info)
        push_it(message)
    

    相关文章

      网友评论

          本文标题:python发送新库提醒到手机

          本文链接:https://www.haomeiwen.com/subject/wvdcdqtx.html