forked from aryan091/python-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnews_application.py
More file actions
70 lines (54 loc) · 2.35 KB
/
news_application.py
File metadata and controls
70 lines (54 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def speak(str):
from win32com.client import Dispatch
speak = Dispatch("SAPI.SpVoice")
speak.Speak(str)
def tellnews(url):
news = requests.get(url=url).text
news = json.loads(news)
arct = news['articles']
for article in arct:
print(article['title'])
speak(article['title'])
speak("Moving to the next news...Listen Carefully")
else:
speak("That all for today.....")
print(len(article))
if __name__ == '__main__':
import requests
import json
print("_____________________NEWS APPILICATION________________")
print("1.Press 1 for Technology Related News")
print("2.Press 2 for Business Related News")
print("3.Press 3 for Entertainment Related News")
print("4.Press 4 for Health Related News")
print("5.Press 5 for Science Related News")
print("6.Press 6 for Sports Related News")
print("Press Any Key for exit")
choice = input("Please enter your choice for particular news")
speak("Please enter your choice for particular news")
if choice == "1":
speak("Technology Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=technology&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
elif choice == "2":
speak("Business Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=business&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
elif choice == "3":
speak("Entertainment Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=entertainment&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
elif choice == "4":
speak("Health Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=health&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
elif choice == "5":
speak("Science Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=science&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
elif choice == "6":
speak("Sports Related Headlines for Today")
url="https://newsapi.org/v2/top-headlines?country=in&category=sports&apiKey=0d23a7184dd047f2afde7fc4bca4f5ae"
tellnews(url)
else:
exit()