Skip to content

Instantly share code, notes, and snippets.

@qolop
Last active June 9, 2016 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qolop/5c095708c57f420dfbae8c3a27f831ac to your computer and use it in GitHub Desktop.
Save qolop/5c095708c57f420dfbae8c3a27f831ac to your computer and use it in GitHub Desktop.
update link formatting
# opens today's South Portland High School announcements in terminal/command prompt
import time
from bs4 import BeautifulSoup as clam_chowder
from urllib.request import urlopen
def main():
dt1 = time.strftime("%Y/%m/%d")
dt2 = time.strftime("%B-%-d-%Y")
url = "http://highschool.spsd.org/riots/{}/{}/".format(dt1, dt2).lower()
print(url)
full_page = urlopen("{}".format(url)).read()
announcement = str(clam_chowder(full_page, "lxml").article.get_text())
print("{}".format(announcement))
if __name__ == "__main__":
if time.strftime("%A") == "Saturday" or time.strftime("%A") == "Sunday":
print("There's no school today. It's the weekend.")
quit()
else:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment