requests Module:
requests is a python module that will allow us to send the HTTP requests to get the data from a particular URL. For example, if we want the data from the above-mentioned URL, then we will send the HTTP request to the site to get the data with the help of requests module.
pprint Module:
pprint module helps us to make our data easily readable.
How we can Download pprint and requests?
General way:
requests => pip install requests
pprint=> pip install pprint
Pycharm users: Go to the project interpreter and install these modules.
Program:
Output:
Now the response is 200 this means that our request is accepted and we can access the data.
As now the data is in the form of JSON so we will load that let's see the code,
Output:
Now you can see the state-wise data.
Now let's see the code for the district (In my case the district is Indore (Madhya Pradesh)).
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer