TelegramAktienBot/telegram_bot/news_fetcher.py
2022-03-15 11:27:54 +01:00

28 lines
828 B
Python

"""
script for news fetching (by keywords)
"""
__author__ = "Florian Kellermann, Linus Eickhoff"
__date__ = "15.03.2022"
__version__ = "0.0.1"
__license__ = "None"
import sys
from newsapi import NewsApiClient
from pandas.io.json import json_normalize
import pandas as pd
# Init
newsapi = NewsApiClient(api_key='4261069558d64489a104ca40df8d2edc')
# /v2/top-headlines
top_headlines = newsapi.get_top_headlines(q='bitcoin', sources='bbc-news,the-verge', language='en')
# /v2/everything
all_articles = newsapi.get_everything(q='bitcoin', sources='bbc-news,the-verge', domains='bbc.co.uk,techcrunch.com', from_param='2022-03-14', to='2022-03-15', language='en', sort_by='relevancy', page=2)
# /v2/top-headlines/sources
sources = newsapi.get_sources()
if __name__ == '__main__':
print(top_headlines)
print(all_articles)