small changes
This commit is contained in:
parent
4fc04fe87d
commit
edcb226c92
13
.env.example
13
.env.example
@ -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=
|
|
@ -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)
|
Loading…
Reference in New Issue
Block a user