Find jokes on a user provided topics using Python Last Updated : 24 Jan, 2021 Comments Improve Suggest changes Like Article Like Report Prerequisites : Http Request methods – Python requestspyfiglet Python requests module helps us make Http requests to specified URL. In this article we will make a json request to this url: https://icanhazdadjoke.com/ and develop a project wherein the user enters any word and the output would be a joke related to that word. We will be using API (library request) to search jokes using a keyword entered by the user if we get multiple results on the keyword entered then one of those jokes will be displayed randomly. Modules Usedrequests module allows us to sent the Https requests using pythonpyfiglet module converts the ASCII texts to ASCII art fontstermcolor module helps us format color in the output terminalrandom module generates random numbers numbers in PythonApproachImport moduleAdd header, to specify in for, is data to be stored, by default it is html text(Here, we are getting data in JSON format)Ask user for inputPass input as searching element to retrieve data from URLPrint retrieved data. Program: Python3 import requests import pyfiglet import termcolor from random import choice header = pyfiglet.figlet_format("Find a joke!") header = termcolor.colored(header, color="white") print(header) term = input("Let me tell you a joke! Give me a topic: ") response_json = requests.get("https://icanhazdadjoke.com/search", headers={"Accept": "application/json"}, params={"term": term}).json() results = response_json["results"] total_jokes = response_json["total_jokes"] print(total_jokes) if total_jokes > 1: print(f"I've got {total_jokes} jokes about {term}. Here's one:\n", choice( results)['joke']) elif total_jokes == 1: print(f"I've got one joke about {term}. Here it is:\n", results[0]['joke']) else: print(f"Sorry, I don't have any jokes about {term}! Please try again.") Output The keyword passes was banana, one of the joke related to is displayed Comment More infoAdvertise with us Next Article Find jokes on a user provided topics using Python P prernaajitgupta Follow Improve Article Tags : Python python-utility Practice Tags : python Similar Reads Python IMDbPY â Retrieving person using person ID In this article we will see how we can retrieve the data of person using its person ID, person id is the unique id given to each person by IMDb. We can use search_person method to search the persons by their name but it gives many people as they have same names therefore retrieving a person by its i 1 min read Python - API.lookup_users() in Tweepy Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from 2 min read Python IMDbPY â Searching a person IMDbPY is a Python package which is used to retrieve and manage the data of the IMDb. In this article we will see how we can search a person with the given name in the IMDb data base, we can do to this with the help of search_person method.  Syntax : imdb_object.search_person(name)Argument : It tak 2 min read Performing Google Search using Python code Let's say you are working on a project that needs to do web scraping but you don't know websites on which scraping is to be performed beforehand instead you are required to perform a google search and then proceed according to google search results to a few websites. In that case, you need google se 2 min read Python IMDbPY - Searching a movie IMDbPY is a Python package which is used to retrieve and manage the data of the IMDb. Python IMDbPY - Searching a movie IMDb is an online database of information related to films, television programs, home videos, video games, and streaming content online â including cast, production crew and person 2 min read Like