Mar 2, 2020
In this post, we have to create a web application using flask which takes news headlines, title, and description from NewsAPI.
Then click on top of the menu item "documentation" and then install the "newsapi".
Now new page is open, after this click on "python", which is on left sidebar:
Click on python and install news API
pip install newsapi-python
Login news api site and get api
937985d39a6144c382769fda00067b7d
NewsApiFlaskApp(project name)
Now in project directory create new directory “templates” and “app.py” file
File Structure:
from flask import Flask
from newsapi import NewsApiClient
app = Flask(__name__)
@app.route('/')
def index():
newsapi = NewsApiClient(api_key="937985d39a6144c382769fda00067b7d")
topheadlines = newsapi.get_top_headlines(sources = )
#------------------------------#
See in the red circle:
#------------------------------code-------------------
from flask import Flask
from newsapi import NewsApiClient
app = Flask(__name__)
@app.route('/')
def index():
newsapi = NewsApiClient(api_key="937985d39a6144c382769fda00067b7d")
topheadlines = newsapi.get_top_headlines(sources = "bbc-news")
article = topheadlines['article']
desc = []
news = []
img = []
for i in range(len(article)):
myarticles = article[i]
news.append(myarticles['title'])
#---------------------------------------------------------
See it in red rectangle
Thanks for reading this, if you need complete custom project then you can contact us at below Gmail:
codersarts@gmail.com
Send your requirements at this.
We are providing other project-related assignments like Java, PHP, C, C++, and more other help services, if you need any other programming help then also send your quote.