Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e21318

Browse files
Merge pull request avinashkranjan#734 from Amit366/Amit1
Desktop notification
2 parents 9847298 + 8898b9c commit 2e21318

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

‎Desktop News Notifier/Readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# <b>Desktop Notifier</b>
2+
3+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
4+
5+
## Desktop Notifier Functionalities : 🚀
6+
7+
- On running the script it gives a notification of top 10 news
8+
9+
## Desktop Notifier Instructions: 👨🏻‍💻
10+
11+
### Step 1:
12+
13+
Open Termnial 💻
14+
15+
### Step 2:
16+
17+
Locate to the directory where python file is located 📂
18+
19+
### Step 3:
20+
21+
Run the command: python script.py/python3 script.py 🧐
22+
23+
### Step 4:
24+
25+
Sit back and Relax. Let the Script do the Job. ☕
26+
27+
### Requirements
28+
29+
- plyer
30+
- requests
31+
- json
32+
33+
## Author
34+
35+
Amit Kumar Mishra
36+

‎Desktop News Notifier/script.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
from plyer import notification
3+
import requests
4+
import json
5+
6+
country_code = input("Enter the country code for the news: ")
7+
api_key = input("Enter the api key: ")
8+
9+
news = requests.get(f'https://newsapi.org/v2/top-headlines?country={country_code}&apiKey={api_key}')
10+
11+
data = json.loads(news.content)
12+
13+
for i in range(10):
14+
15+
notification.notify(
16+
title = data['articles'][i]['title'][:20],
17+
message= data['articles'][i]['description'][:44] ,
18+
# displaying time
19+
timeout=5 ,
20+
toast=False)
21+
22+
23+
24+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /