from newsapi.sources import Sources
import json
api_key ='*******************'
s = Sources(API_KEY=api_key)
they input the category of news they want
wanted = input('> ')
source_list = s.get(category=wanted, language='en')
index = 0
sources = []
getting the sources for source in source_list["sources"]:
data = json.dumps(source_list)
data = json.loads(data)
source = (data["sources"][index]["url"])
sources.append(source)
index += 1
from newspaper import Article
i = len(sources) - 1
looping through the source list and printing the articles for source in sources:
url_ = sources[i]
a = Article[url_]
print(a)
i -= 1
getting error 'type' object is not subscriptable on the line a = Article[url_] have researched but still do not understand why in my case.
newspapersis a module. newspaper.readthedocs.io/en/latest