Skip to content

Instantly share code, notes, and snippets.

@athyk
Created February 27, 2021 09:35
Show Gist options
  • Save athyk/cfd1b44b472a99becdcce4f136882566 to your computer and use it in GitHub Desktop.
Save athyk/cfd1b44b472a99becdcce4f136882566 to your computer and use it in GitHub Desktop.
Python get the current event in Time.is
import requests
import bs4 as bs
headers = {
'cache-control': 'no-cache',
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
}
a = requests.get("https://time.is", headers=headers)
soup = bs.BeautifulSoup(a.text,'lxml')
supa = soup.find('div',attrs={'id' : 'daydiv'})
day = supa.find('a').contents[0]
print(f"Today is {day}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment