Source | GitPython
01 \ * * * *
Description of project
You should know that Github project updates are notified by email, and we usually do not use email very much! \
So, if the project updates, how can we timely find, and open the project home page?
Project Address:
Github.com/kenwoodjw/p…
02 * * * *
Implementation process ****
1) Data acquisition
Github officially provides a detailed data interface, and data is stored as Json strings.
Data address of the project:
Api.github.com/repos/kenwo…
The data address for each item, similar to the local disk directory.
We can get the update time from the URL of the data interface.
import request
# 1.Github project and API interface data
api = 'https://api.github.com/repos/kenwoodjw/python_interview_question'
web_page = "https://github.com/kenwoodjw/python_interview_question # 2. All_info = requests. Get (API).json() # 3 Cur_update = all_info['updated_at'] print(cur_update)Copy the code
2) Regularly monitor data changes
3) Open the web page
Set a loop to retrieve update_AT data every 10 minutes. If the time is inconsistent, the data is updated and the project home page is automatically opened.
while True:
all_info = requests.get(api).json()
cur_update = all_info['updated_at']
print(cur_update)
# assume that the last update time was not known before the first run
# if last_update is none, execute the following statement to return the current time to the last time
if not last_update:
last_update = cur_update
The first time the two times are equal, the execution will not be executed
# if after 10 minutes, cur_update will be updated, then the page will open automatically
Next, assign the current time to the last time
# Start a new round of monitoring
if last_update < cur_update:
webbrowser.open(web_page)
last_update = cur_update
Repeat the while loop 10 minutes apart to see if the new update time has changed
time.sleep(600)
Copy the code