Code

Making Requests in Python

HTTP requests are very simple to make using the Requests module. Use the following functions to make any kind of basic HTTP request:

requests.get('https://api.placeholderurl.com') requests.post('https://placeholderurl.com/post', data = {'key', 'value'}) requests.put('https://placeholderurl.com/put', data = {'key', 'value'}) requests.delete('https://placeholderurl.com/delete') requests.head('https://placeholderurl.com/get') requests.options('https://placeholderurl.com/get')

Each function requires a URL parameter as a string, and both post and put require a dictionary parameter containing the relevant data you would like to send. Each function returns a Response object.

0

1

Updated 2021-05-10

Tags

Python Programming Language

Data Science