Coder Social home page Coder Social logo

urbandictionary.py's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.