Created
February 27, 2021 09:35
-
-
Save athyk/cfd1b44b472a99becdcce4f136882566 to your computer and use it in GitHub Desktop.
Python get the current event in Time.is
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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