Pragmatism | How to happily learn from the boss?

Pragmatism | How to happily learn from the boss?

As a programmer, github is one of the websites we often use.

But there are too many big guys above, and there are various very awesome open source projects. In order to achieve my purpose of learning (zhuang) and learning (bi), I follow many big guys and see which projects the big guys have starred. Follow The pace of the boss.

Although github has an e-mail reminder function, but to be honest, except for the work mailbox that is often used, the rest of the mailboxes are only checked occasionally. There is no way to meet my needs to know the dynamics of the big guys the first time, so I had to do it myself.

Analyze the needs

Take Cui University's github as an example. We first need to get the projects on Cui University's github star. When a new project appears, we will remind us or open the project page.

Start coding

1. we find the api about the user star project on github:

https://api.github.com/users/{USERNAME}/starred

Secondly, analyze the information returned by accessing the api and open it with a browser to see that the content format displayed on the page is json, and the id in json is the unique identifier of the star item.

We only need to get all the IDs, and when a new project ID appears, remind us to complete our needs to keep up with the big guys.

Full code

Take Cui University's github as an example. When there is a new star project, open the project address for us and check it every 10 minutes:

import requests
import webbrowser
import time
# api specifies all the projects of the person star who is following, and the user is Germey
api = "https://api.github.com/users/Germey/starred"
# Visit the api first to get the star list
info = requests.get(api).json()
starred = []
# Store the item id in the star list into the list variable
for i in info:
    starred.append(i['id'])

while True:
    # Get the project of star
    info = requests.get(api).json()
    for i in info:
        # If the current project id does not exist in the list variable, it means it is the project just star
        if not i['id'] in starred:
            starred.append(i['id'])
            # Get project name
            repo_name = i['name']
            # Get author name
            owner = i['owner']['login']
            # Open the project in the browser
            web_page = "https://github.com/" + owner + "/" + repo_name
            webbrowser.open(web_page)
    # Check every 600 seconds (10 minutes)
    time.sleep(600)

This completes the purpose of learning (zhuang) and learning (bi).

Reference: https://cloud.tencent.com/developer/article/1518477 Pragmatism | How to follow the boss and learn happily? -Cloud + Community-Tencent Cloud