diff options
author | noa | 2024-01-03 10:16:53 +0000 |
---|---|---|
committer | noa | 2024-01-03 10:16:53 +0000 |
commit | 50556112d256e05ccc869044a2cb1b857abc296b (patch) | |
tree | 7ff6e0f67674b6116fde1fa188f7da5bf08000df |
Add wotd command.
Wotd grabs the word of the day from the front page of the oxford english dictionary website.
-rwxr-xr-x | wotd | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/wotd b/wotd new file mode 100755 index 0000000..933a021 --- /dev/null +++ b/wotd @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +from urllib.request import Request, urlopen +from bs4 import BeautifulSoup + +req = Request("https://www.oed.com/", headers={"User-Agent": "Mozilla/5.0"}) +soup = BeautifulSoup(urlopen(req), "html.parser") + +#wotd_div = soup.find('div', attrs={'class': 'wotd'}) +#wotd_word = word_div.find('a').get_text() +wotd_word = soup.find("div", attrs={"class": "wotd"}).h3.a.get_text() + + +print("The oxford english dictionary word of the day is " + wotd_word + "!") + |