December 2018
Beginner to intermediate
796 pages
19h 54m
English
Let's now explore a couple of examples on HTTP requests. I will use the requests library for these examples, which you can install with pip. We're going to perform HTTP requests against the httpbin.org API, which, interestingly, was developed by Kenneth Reitz, the creator of the requests library itself. This library is amongst the most widely adopted all over the world:
import requestsurls = { 'get': 'https://httpbin.org/get?title=learn+python+programming', 'headers': 'https://httpbin.org/headers', 'ip': 'https://httpbin.org/ip', 'now': 'https://now.httpbin.org/', 'user-agent': 'https://httpbin.org/user-agent', 'UUID': 'https://httpbin.org/uuid',}def get_content(title, url): resp = requests.get(url) print(f'Response for ...Read now
Unlock full access