Skip to content

Borgotto/urbandictionary.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urbandictionary.py 📚

A web scraper written in Python to extract words from https://www.urbandictionary.com/

Requirements:

cd to the repo folder and install via pip install -r requirements.txt command

Features:

  • pretty much everything you can do through the website but without graphical interface
    (except for user-related stuff like login, vote or submit new definitions)
Feature State
get words from the main page ✔️
search for a specific definition ✔️
fetch random words ✔️
get words votings
user log-in
add definitions
ability to vote

Usage:

  • print words from the main page

from urban_dictionary import UrbanDictionary

ud = UrbanDictionary()

word_of_the_day = ud.word
print("Today's WOTD is", word_of_the_day.name)

if ud.has_next_word:
    word = ud.go_to_next_word()
    print("Yesterday's WOTD was", word.name)

if ud.has_next_page:
    ud.go_to_next_page()
    print("Last week's WOTD was", ud.word.name, end="\n\n")
  • search for specific words

ud = UrbanDictionary("meaning of life")

# Be sure to check that there's actually a definition for that word
if ud.word is None:
    print("no definition")
else:
    print("Top definition for 'meaning of life' is:\n" +
          ud.word.meaning, end="\n\n")
  • you can also get random words

ud = UrbanDictionary(random=True)

# There's always going to be a word to get, no checks needed
print("Feeling lucky? Here's a random word:\n" +
      ud.word.name + "\n" +
      ud.word.example, end="\n\n")

# Let's get another random page full of random words
ud.go_to_previous_page()
print("Another random word:\n" +
      ud.word.name + "\n" +
      ud.word.example, end="\n\n")
please, please, please send feedback

About

A web scraper written in Python to extract words from https://www.urbandictionary.com/

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages