Skip to content

Instantly share code, notes, and snippets.

@nikteg
Last active March 15, 2021 16:13
Show Gist options
  • Save nikteg/c14d88d60bf6e874e1e29299d03bfd74 to your computer and use it in GitHub Desktop.
Save nikteg/c14d88d60bf6e874e1e29299d03bfd74 to your computer and use it in GitHub Desktop.
Bitbar Golden Hour
#!/usr/bin/env LC_ALL=en_US.UTF-8 /usr/local/bin/python3
#
# <bitbar.title>Golden hour</bitbar.title>
# <bitbar.version>v0.3</bitbar.version>
# <bitbar.author>nikteg</bitbar.author>
# <bitbar.author.github>nikteg</bitbar.author.github>
# <bitbar.desc></bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies>python</bitbar.dependencies>
from urllib.request import urlopen, Request
from bs4 import BeautifulSoup
country = "sweden"
city = "goteborg"
css_selector = "avond_goudenhour"
url = "https://meteogram.org/sun/" + country + "/" + city + "/"
request = Request(url)
r = urlopen(request).read()
soup = BeautifulSoup(r, 'html.parser')
print(soup.find("td", css_selector).text + " | sfimage=sunset")
print("---")
print(soup.find("meta", { "name": "description" }).get("content").split("-")[0].strip() + " | href='" + url + "'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment