zemmsoares / polybar-news Goto Github PK
View Code? Open in Web Editor NEW๐ฐ News display module for Polybar & i3blocks
License: MIT License
๐ฐ News display module for Polybar & i3blocks
License: MIT License
I installed everything, and believe I have it all set up. I'm assuming I was also required to chmod +x all of the scripts correct?
When I go to try the python script to check that it is pulling news I get the following:
Traceback (most recent call last):
File "/home/myusername/.config/polybar/scripts/news/news.py", line 32, in <module>
f = open(path, "w")
FileNotFoundError: [Errno 2] No such file or directory: '~/home/myusername/.config/polybar/scripts/news/current_news.txt'
There is a blank copy of current_news.txt in that listed folder.
my news.py
#!/usr/bin/python
import requests
import os.path
#path where news are saved in txt (default current directory)
save_path ='~/home/myusername/.config/polybar/scripts/news'
#get your api key at https://newsapi.org/
api_key = "my api key"
#find sources & country codes at https://newsapi.org/sources
sources = "ign,bbc-news"
country = ""
# save_url saves URL so that it is possible to open the news in the browser
# the url will always be the most recent, enable if number_news = 1
save_url = False
number_news = 3
try:
data = requests.get('https://newsapi.org/v2/top-headlines?apiKey='+api_ key+'&sources='+sources+'&country='+country).json()
news_string = ""
for x in range(number_news):
sourceName = data['articles'][x]['source']['name']
title = data['articles'][x]['title']
news_string += '['+sourceName+ '] '+ title + ' '
path = os.path.join(save_path,"current_news.txt")
f = open(path, "w")
f.write(news_string)
f.close()
if save_url == True:
url = data['articles'][0]['url']
path = os.path.join(save_path,"current_url.txt")
f = open(path, "w")
f.write(url)
f.close()
except requests.exceptions.RequestException as e:
What am I doing wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.