Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding method for getting word of the day #129

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions duden/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ def get(word, cache=True):
return DudenWord(soup)


def get_word_of_the_day():
"""
Scrapes the word of the day and returns DudenWord instance of it.

"""
html_content = requests.get("http://www.duden.de").content
soup = bs4.BeautifulSoup(html_content, features="lxml")
link = soup.find("a", class_="scene__title-link").get("href")
word_start_index = link.rfind("/") + 1
word = link[word_start_index:]

return get(word)


def get_search_link_variants(link_text):
"""
Lists possible interpretations of link text on search page.
Expand Down