January 2019
Beginner
318 pages
8h 23m
English
In this section, we are going to learn how to use RESTful APIs. To do this, we are going to use the requests and JSON modules of Python. We will see an example now. First, we are going to use the requests module to get the information from an API. We will see GET and POST requests.
First, you must install the requests library as follows:
$ pip3 install requests
Now, we will see an example. Create a rest_get_example.py script and write the following content in it:
import requestsreq_obj = requests.get('https://www.imdb.com/news/top?ref_=nv_tp_nw')print(req_obj)
Run the script and you will get the output as follows:
student@ubuntu:~/work$ python3 rest_get_example.pyOutput:<Response [200]>
In the ...
Read now
Unlock full access