-
Notifications
You must be signed in to change notification settings - Fork 1
/
Aakhbar_Padke_Sunao.py
150 lines (102 loc) · 4.08 KB
/
Aakhbar_Padke_Sunao.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import json
import time
def speak(str):
from win32com.client import Dispatch
speak=Dispatch('SAPI.SpVoice')
speak.Speak(str)
if __name__ == '__main__':
import requests
url1 =('https://newsapi.org/v2/top-headlines?country=in&category=technology&sortBy=publishedAt&apiKey=1cb5d20289cb4960b610dc1205b16c55')
url =('https://newsapi.org/v2/top-headlines?country=in&category=science&sortBy=publishedAt&apiKey=1cb5d20289cb4960b610dc1205b16c55')
response = requests.get(url)
response1 = requests.get(url1)
JS_on = json.loads(response1.text)
a =response.json()
for j in range((10)):
speak(response.json()["articles"][j]["title"])
time.sleep(0.5)
speak(f"Next {j+1}st news is:")
# print(response.text)
# print(JS_on)
for i in range(JS_on["totalResults"]):
# print(i)
# if i == "article":
print(JS_on["articles"][i]["title"])
print(JS_on["articles"][i]["description"])
print(JS_on["articles"][i])
speak(JS_on["articles"][i]["title"])
speak(JS_on["articles"][i]["description"])
time.sleep(0.5)
speak("Next news is:")
speak("Thanks for paying attention .. See you tomorrow!!")
#--------------------------------------------------------Harry's code--------------------------------------------------------------------
# Akhbaar padhke sunaao
import requests
import json
def speak(str):
from win32com.client import Dispatch
speak = Dispatch("SAPI.SpVoice")
speak.Speak(str)
if __name__ == '__main__':
speak("News for today.. Lets begin")
url = "https://newsapi.org/v2/top-headlines?sources=the-times-of-india&apiKey=d093053d72bc40248998159804e0e67d"
news = requests.get(url).text
news_dict = json.loads(news)
arts = news_dict['articles']
for article in arts:
speak(article['title'])
print(article['title'])
speak("Moving on to the next news..Listen Carefully")
speak("Thanks for listening...")
#--------------------------------------------------------Alok's code--------------------------------------------------------------------
#--------------------------------------------------------It gives link for more reading --------------------------------------------------------------------
import requests
import json
from win32com.client import Dispatch
def speak(string):
speak=Dispatch('SAPI.spVoice')
speak.speak(string)
url = ('https://newsapi.org/v2/top-headlines?'
'country=in&'
'apiKey=XXXXXXXXXX')
data=requests.get(url=url)
india=data.json()
print(india['articles'][0]['description'])
for i in range(20):
print(i,india['articles'][i]['source']['name'])
no=int(input("choose newspaper name"))
speak(india['articles'][no]['title'])
print("for more ",india['articles'][no]['url'])
speak(india['articles'][no]['content'])
speak(india['articles'][no]['description'])
#--------------------------------------------------------Avinash's code--------------------------------------------------------------------
#--------------------------------------------------------It shows the news Computer is reading sideways ------------------------------------------
#--------------------------------------------------------Better code till now--------------------------------------------------------------------
import requests
import json
import time
from win32com.client import Dispatch
def speak(s):
speak = Dispatch("SAPI.SpVoice")
speak.Speak(s)
data = requests.get("https://newsapi.org/v2/top-headlines?country=in&apiKey=YourAPIKEY")
result = data.json()
print(result['status'])
# print(result)
news = result['articles']
speak("Welcome to the CodeWithHarry News Channel")
speak("Here are the top ten news of the awesome country India")
speak("So our first news is ")
for i in range(0,10):
print(i)
print(news[i]['description'])
speak(news[i]['description'])
if i>=9:
break
time.sleep(2)
if i == 8:
speak("So our last news for today is ")
else:
speak("Moving To Our next news")
speak("Thanks for listening ! Have a nice day")
speak("Keep coding")