Created
January 11, 2019 12:34
-
-
Save bera5186/d6b142a380f184e39b6c5d6073918dd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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