Exercise 9: Akhbaar Padhke Sunaao | Python Tutorials For Absolute Beginners In Hindi #83



Source Code/Additional Material –
►Full Python tutorials for absolute beginners (Hindi) playlist –
►Click here to subscribe –

Best Hindi Videos For Learning Programming:

►Learn Python In One Video –

►Learn JavaScript in One Video…

, , , , , , , , ,

42 thoughts on “Exercise 9: Akhbaar Padhke Sunaao | Python Tutorials For Absolute Beginners In Hindi #83

  1. def speak(str):

    from win32com.client import Dispatch

    speak=Dispatch("SAPI.spVoice")

    speak.Speak(str)

    if _name_ == '__main__':

    import requests

    import json

    url = ('https://newsapi.org/v2/top-headlines?'

    'sources=bbc-sport&'

    'apiKey=49e391e7066c4158937096fb5e55fb5d')

    response = requests.get(url)

    text = response.text

    my_json = json.loads(text)

    for i in range(0, 11):

    speak(my_json['articles'][i]['title'])

  2. Sir maine code likha hae Par meri ek request hae apse ki aap meri website
    https://raj-chatroom.tk please visit kare

    # Source Code

    import requests

    # speak funtion mere linux (ubuntu) me nahi chal raha hae

    api_key = 'Your Api Key'
    url = (f'https://newsapi.org/v2/top-headlines?sources=google-news-in&apiKey={api_key}')

    response = requests.get(url)
    data = response.json()

    def speak(text):
    from win32com.cilent import Dispatch
    speak = Dispatch("SAPI.Spvoice")
    speak.speak(text)

    # print(data['articles'][0]['title'])
    for articles in data['articles']:
    speak(articles['title'])

  3. Solution 2:

    import requests as req

    import json

    news = req.get("https://newsapi.org/v2/top-headlines?sources=the-times-of-india&apiKey=&quot😉

    x= news.json()

    news_articles = x['articles']

    count = 0

    for i in news_articles:

    FinalNews= "Aaj ki taza khbar "+ str(count+1)+ " is>> " + str(i['title'])

    print (FinalNews)

    count += 1

    if count == 9:

    break

    def speak(str):

    from win32com.client import Dispatch

    speak= Dispatch("SAPI.spvoice")

    speak.speak(str)

    if _name_ == "__main__":

    speak(FinalNews)

  4. 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'])

  5. First Solution:
    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&quot😉

    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")

    Harry bhai this is my code.Please reply if any optimization needed for this code

  6. import urllib.request as urlr

    import json

    news = urlr.urlopen("https://newsapi.org/v2/top-headlines?sources=the-times-of-india&apiKey=7a6de22545a64ba595d29ffee62e2931&quot😉

    jsonnews= news.read()

    x= json.loads(jsonnews.decode())

    for i in range(0,10):

    FinalNews= "Aaj ki taza khbar"+ str(i+1)+ "is" + x['news'] [i] ['news title']

    def speak(str):

    from win32com.client import Dispatch

    speak= Dispatch("SAPI.spvoice")

    speak.speak(str)

    if _name_ == "__main__":

    speak("FinalNews")

  7. Haary Bhai, kya mai ise flask se run kar sakta hu?
    error aa raha hai flask se try karne pe.

    part of my code

    from win32com.client import Dispatch
    @app.route("/speak")
    def speak():

    speak= Dispatch("SAPI.SpVoice")
    speak.Speak("how are you smith")

  8. #Akhbaar Padhke Sunaao

    import requests

    url = 'https://newsapi.org/v2/top-headlines?country=in&apiKey=e50fa53a9129421ebf69446095ebd1d1'

    country = 'in'

    api_keys = 'xxxxxxxxxxxxxxxxxxxxxxxx'

    #

    for i in range(1):

    payload = {

    'page':i,

    'country': 'in',

    'api_keys': 'xxxxxxxxxxxxxxxxxxxxxx',

    'pageSize':10

    }

    r=requests.get(url=url, params=payload)

    data=r.json()

    # print(i)

    list_view = data['articles']

    for items in list_view:

    news = items["title"]

    # print(news)

    print(f"{list_view.index(items)}", news)

    def speak(str):

    from win32com.client import Dispatch

    speak = Dispatch("SAPI.SpVoice")

    speak.Speak(str)

    if _name_ == '__main__':

    speak("Hello !! Mr. Programmer ,Today news headlines :" )

    for items in list_view:

    speak(items["title"])

    # speak(news)

  9. def speak(api_key, category):

    import requests, json

    from win32com.client import Dispatch

    url = f"https://newsapi.org/v2/top-headlines?country=in&category={category}&apiKey={api_key}"

    speak = Dispatch("SAPI.Spvoice")

    json_data = requests.get(url).json()

    count = 1

    index = 0

    news_num = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"]

    while count < 11:

    news = json_data["articles"][count]["description"]

    speak.Speak(f"{news_num[index]} news is {news}")

    count = count + 1

    index = index + 1

    speak.Speak(news)

    if _name_ == "__main__":

    print("n <– Aaj ki Top 10 Khabre janiye bina Padhe –> n")

    api_key = str(input("–> Enter you API key from Newsapi.org: "))

    category = input("nCategories: nt 1. business nt 2. entertainment nt 3. health nt 4. science nt 5. sports nt 6. technology nn –> Enter the same name of category which you want: ")

    speak(api_key, category)

  10. def readnews():

    from newsapi import NewsApiClient

    key=input("Write your api_key:")

    newsapi = NewsApiClient(api_key=key)

    top_headlines = newsapi.get_top_headlines(

    sources='google-news-in',

    language='en')

    article = top_headlines["articles"]

    list1 = []

    a=input("If you want to listen title of the news then write titlenFor description of the news write description n")

    for i in article:

    list1.append(i[f"{a}"])

    result = f"next {a} is ".join(map(str, list1))

    return result

    def speak(str):

    from win32com.client import Dispatch

    speak=Dispatch("SAPI.SpVoice")

    speak.Speak(str)

    if _name_ == '__main__':

    print("!!!!!Today's top_headlines of the news!!!!!")

    try:

    news=readnews()

    speak(news)

    except:

    print("Something Went Wrong!!!")

Leave a Reply

Your email address will not be published. Required fields are marked *