diff --git a/scripts/Meaning_Grepper/.env.example b/scripts/Meaning_Grepper/.env.example new file mode 100644 index 0000000..ab949aa --- /dev/null +++ b/scripts/Meaning_Grepper/.env.example @@ -0,0 +1 @@ +UD_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/scripts/Meaning_Grepper/README.md b/scripts/Meaning_Grepper/README.md new file mode 100644 index 0000000..1c945a4 --- /dev/null +++ b/scripts/Meaning_Grepper/README.md @@ -0,0 +1,13 @@ +## py_Online_Meaning_Grepper +Simple Python Program for finding meaning of the word. +> Uses https://rapidapi.com/community/api/urban-dictionary for API Calls. +### Requirements +```bash +pip install json requests python_dotenv +``` + +### Run Program +```bash +python script.py +``` + diff --git a/scripts/Meaning_Grepper/requirements.txt b/scripts/Meaning_Grepper/requirements.txt new file mode 100644 index 0000000..85aa745 --- /dev/null +++ b/scripts/Meaning_Grepper/requirements.txt @@ -0,0 +1,3 @@ +json +requests +python-dotenv diff --git a/scripts/Meaning_Grepper/script.py b/scripts/Meaning_Grepper/script.py new file mode 100644 index 0000000..d23821a --- /dev/null +++ b/scripts/Meaning_Grepper/script.py @@ -0,0 +1,32 @@ +import requests +import json +import os +from dotenv import load_dotenv + +load_dotenv() + +UD_API_KEY = os.environ.get("UD_API_KEY") + +word = str(input("Enter Word : ")) + +url = "https://mashape-community-urban-dictionary.p.rapidapi.com/define" + +querystring = {"term":word} + +headers = { + "X-RapidAPI-Key": UD_API_KEY, + "X-RapidAPI-Host": "mashape-community-urban-dictionary.p.rapidapi.com" +} + +response = requests.request("GET", url, headers=headers, params=querystring) +json_str = json.dumps(response.text) +y = json.loads(response.text) +print( +"\n", +"Showing Results for", y["list"][0]["word"], "\n", +"Definition : ", y["list"][0]["definition"], "\n", +"Permalink " , y["list"][0]["permalink"], "\n", +"Written On : " , y["list"][0]["written_on"], "\n", +"Example : " , y["list"][0]["example"], "\n", +"Author : " , y["list"][0]["author"], "\n", +)