50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
|
|
import sys
|
|
import os
|
|
import threading
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
import time
|
|
import csv
|
|
|
|
from rgbmatrix import RGBMatrix, RGBMatrixOptions
|
|
from stockTicker import StockTicker
|
|
import finnhub
|
|
|
|
import pexpect
|
|
from pycoingecko import CoinGeckoAPI
|
|
from newsapi import NewsApiClient
|
|
|
|
import sys, os
|
|
try:
|
|
raise NotImplementedError("No error")
|
|
except Exception as e:
|
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
|
print(exc_type, fname, exc_tb.tb_lineno, exc_obj, exc_tb)
|
|
|
|
if __name__ == '__main__':
|
|
|
|
newsapi = NewsApiClient(api_key='cf08652bd17647b89aaf469a1a8198a9')
|
|
|
|
top_headlines = newsapi.get_top_headlines(q='bitcoin',
|
|
category='business',
|
|
country='us')
|
|
|
|
|
|
'''
|
|
top_headlines = newsapi.get_everything(q='bitcoin',
|
|
sources='bbc-news,the-verge',
|
|
page=1)
|
|
'''
|
|
#print(top_headlines)
|
|
headline_titles = [top_headline['title'] for top_headline in top_headlines['articles']]
|
|
headline_ids = [top_headline['source']['name'] for top_headline in top_headlines['articles']]
|
|
headline_times = [top_headline['publishedAt']for top_headline in top_headlines['articles']]
|
|
|
|
#print([top_headline.keys()for top_headline in top_headlines['articles']])
|
|
print(headline_titles)
|
|
print(headline_ids)
|
|
print(headline_times)
|
|
|
|
|