diff --git a/RandomQuotegenerator/README.md b/RandomQuotegenerator/README.md new file mode 100644 index 000000000..3db6ec2df --- /dev/null +++ b/RandomQuotegenerator/README.md @@ -0,0 +1,3 @@ +Reading a quote daily may boost you in different aspects. But, it will take time to surf the internet every day for quotes. So, how to save time? +I have created this automate that repeated process using Python. +This a project made usinh python. I have used the Quote Garden API to get a random quote.The project will give you random quotes every time you run the function. diff --git a/RandomQuotegenerator/randomquotegenerator.py b/RandomQuotegenerator/randomquotegenerator.py new file mode 100644 index 000000000..adbd1cf3c --- /dev/null +++ b/RandomQuotegenerator/randomquotegenerator.py @@ -0,0 +1,22 @@ +import requests + + +## function that gets the random quote +def get_random_quote(): + try: + ## making the get request + response = requests.get("https://quote-garden.herokuapp.com/api/v3/quotes/random") + if response.status_code == 200: + ## extracting the core data + json_data = response.json() + data = json_data['data'] + + ## getting the quote from the data + print(data[0]['quoteText']) + else: + print("Error while getting quote") + except: + print("Something went wrong! Try Again!") + + +get_random_quote()