TelegramAktienBot/telegram_bot/news_fetcher.py

28 lines
828 B
Python
Raw Normal View History

2022-03-15 08:05:28 +00:00
"""
script for news fetching (by keywords)
"""
__author__ = "Florian Kellermann, Linus Eickhoff"
__date__ = "15.03.2022"
__version__ = "0.0.1"
2022-03-15 09:39:29 +00:00
__license__ = "None"
import sys
from newsapi import NewsApiClient
from pandas.io.json import json_normalize
import pandas as pd
2022-03-15 10:27:54 +00:00
# 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()
2022-03-15 09:39:29 +00:00
if __name__ == '__main__':
2022-03-15 10:27:54 +00:00
print(top_headlines)
print(all_articles)