Skip to content

Instantly share code, notes, and snippets.

@bera5186
Created January 11, 2019 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bera5186/d6b142a380f184e39b6c5d6073918dd9 to your computer and use it in GitHub Desktop.
Save bera5186/d6b142a380f184e39b6c5d6073918dd9 to your computer and use it in GitHub Desktop.
import requests
import sys
from bs4 import BeautifulSoup as bs
base_url = 'https://www.dictionary.com/browse/'
try:
querry = sys.argv[1]
except:
print("Enter The World !")
exit(-1)
try:
r = requests.get(base_url+str(querry))
except:
print('Something Wrong ! Please check your internet connection')
exit(-1)
soup = bs(r.content, 'html.parser')
try:
adj = soup.find('span', attrs={'class':'luna-pos'})
definitions = soup.find_all("ol")
meanings = definitions[0].findChildren("li", recursive=False)
except:
print("Word Not Found !")
exit(-1)
print(querry, " ("+adj.text+")")
for i in range(len(meanings)):
print(i+1,".", meanings[i].text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment