Advertisement
webbersof

News app

Feb 4th, 2022
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. def speak(str):
  2. from win32com.client import Dispatch
  3. speak = Dispatch("SAPI.SpVoice")
  4. speak.Speak(str)
  5.  
  6. if __name__ == '__main__':
  7. import requests
  8. import json
  9.  
  10. query_params = {
  11. "source": "bbc-news",
  12. "sortBy": "top",
  13. "apiKey": "4dbc17e007ab436fb66416009dfb59a8"
  14. }
  15. main_url = " https://newsapi.org/v1/articles"
  16. res = requests.get(main_url, params=query_params)
  17. load = json.loads(res.text)
  18. speak('Here you listen top BBC news from SoftUni Fundamentals Team. Lets began')
  19. speak('first news')
  20.  
  21. for i in range(4):
  22. print(load['articles'][i]['title'])
  23. speak(load['articles'][i]['title'])
  24. if i < 3:
  25. speak('next news')
  26. else:
  27. speak('This was top 4 BBC news from SoftUni Fundamentals Team.See you Soon')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement