On github site to find certain items in line with the conditions, and pushover push notifications to your phone

Locate the item meets the following criteria (meet), and push notifications to your phone on github website: 
1, issued within the last week;
2, Star number is greater than 200;
3, Topic is blockchain

find repo the API (topic is blockchain, creation date after the 2020 March 3):
https://api.github.com/search/repositories?q=topic:blockchain+created:>2020-03-03&sort=stars

qualify directly found the repo, without the filter (topic is blockchain, creation date after 2020 March 3, the star number than 200) in the program:
https://api.github.com/search/repositories?q=topic : blockchain + created:> 2019-03-03 + stars:> 200

Find the repo API (topic is blockchain, in descending order by date update, you can not sort by creation date):
https://api.github.com/search/ repositories q = topic:? blockchain & sort = updated & order = desc

push notification to your phone with pushover, only 7 days of free access to information as follows:
djlapp1, API Token / Key: individuals sign up for a
User Key: get the personal registration

notification is sent to the phone template API (POST mode):
https://api.pushover.net/1/messages.json?token={t}&user={u}&title={title}&message={message}&url={url} 

ideas: find repo ---- construction send content to send notifications ----
import requests

def get_repo(date='2020-03-03',topic='blockchain'):   #  找到指定topic的近期好仓库
    api_template = 'https://api.github.com/search/repositories?q=topic:{topic}+created:>{date}&sort=stars'
    repo_api = api_template.format(topic=topic,date=date)
    print('repo_api:',repo_api)
    repos = []
    try:
        repos_info = requests.get(repo_api).json()['items']
        for repo in repos_info:
            if repo['stargazers_count'] > 200:
                repos.append({'name': repo['name'], 'id': repo['id'],'description':repo['description'],
                              'url': repo['html_url']}) 
        Print ( 'problem GitHub interface to obtain data')
    The except:
    Repos return 
    try:


def make_pushapi (repo): API # configured to send a notification of the individual, repo is described in a dictionary database 
    pushapi_template = 'https://api.pushover.net/1/messages.json?token={t}&user={u } & title = {title} & Message = {Message} & URL = {URL} ' 
    title =' a library on blockchain the new: '+ the repo [' name '] 
    Message =' name: '+ the repo [' name '] + 'ID:' + STR (the repo [ 'ID']) + 'Description:' + the repo [ 'Description'] 
    URL = the repo [ 'URL'] 
    push_api = pushapi_template.format ( 
        T = 'xxxxxxxxxxxxxxxxxx', 
        U = 'XXXXXXXXXXXXXX ', 
        title = title, 
        Message = Message, 
        URL = URL 
    ) 
    return push_api 

DEF push_notice (push_api):# Single push notification to your phone 
        requests.post (push_api) 
        Print ( 'successfully sent a') 
    the except: 
        Print ( 'sending a failure, the service interface may be a problem pushover') 

DEF make_and_push_notice (the repo): # additional method for constructing a transmission request 
    push_api = 'https://api.pushover.net /1/messages.json ' 
    Data = { 
        ' token ':' XXXXXXXXX ', 
        ' User ':' XXXX ', 
        ' title ':' a new library of about blockchain: '+ the repo [' name '], 
        ' Message ':' name: '+ the repo [' name '] +' ID: '+ STR (the repo [' ID ']) +' Description: '+ the repo [' Description '], 
        ' URL ': the repo [' URL ' ] 
    } 
    requests.post (push_api, Data) 

Repos = get_repo ( '2019-03-03') 
Print ( "qualifying warehouse volume: 'len (Repos)) 
Print ( 'qualifying warehouse:', Repos) 
for repo in Repos: 
    push_notice (make_pushapi (repo))

  

Guess you like

Origin www.cnblogs.com/djlbolgs/p/12513828.html