implemented /news and deleted debugbot (edit BOT_API_KEY instead) #2

Merged
Rripped merged 40 commits from bot-features into main 2022-03-16 09:08:43 +00:00
2 changed files with 13 additions and 17 deletions
Showing only changes of commit edcb226c92 - Show all commits

View File

@ -1,13 +0,0 @@
# MYSQL Database
MYSQL_HOST=
MYSQL_PORT=
MYSQL_DATABASE=
MYSQL_USER=
MYSQL_PASSWORD=
# Telegram bot api key
BOT_API_KEY=
# Flask secret key
SECRET_KEY=

View File

@ -7,13 +7,18 @@ __version__ = "0.0.1"
__license__ = "None" __license__ = "None"
import sys import sys
from newsapi import NewsApiClient import os
from pandas.io.json import json_normalize
import json import json
import pandas as pd import pandas as pd
from newsapi import NewsApiClient
from dotenv import load_dotenv
load_dotenv()
# Init # Init
newsapi = NewsApiClient(api_key='4261069558d64489a104ca40df8d2edc') newsapi = NewsApiClient(api_key=os.getenv('NEWS_API_KEY'))
# /v2/top-headlines # /v2/top-headlines
top_headlines = newsapi.get_top_headlines(q='bitcoin', sources='bbc-news,the-verge', language='en') top_headlines = newsapi.get_top_headlines(q='bitcoin', sources='bbc-news,the-verge', language='en')
@ -39,5 +44,9 @@ def format_article(article):
return formatted_article return formatted_article
if __name__ == '__main__': if __name__ == '__main__':
print("fetching top news by keyword business...")
articles = get_top_news_by_keyword("business") articles = get_top_news_by_keyword("business")
formatted_article = format_article(articles["articles"][0]) formatted_article = format_article(articles["articles"][0])
print(formatted_article)