Visão Geral
O curso Python Requests Foundation é uma introdução abrangente à biblioteca Requests, uma das mais populares para fazer requisições HTTP em Python. Durante o curso, os alunos aprenderão como realizar requisições web, interagir com APIs, e manipular respostas HTTP de forma prática e eficiente. O Requests simplifica o processo de comunicação com a web, permitindo que desenvolvedores criem e consumam APIs com facilidade. O curso é voltado tanto para iniciantes quanto para profissionais que desejam dominar a comunicação via HTTP em seus projetos Python.
O curso Python Requests Foundation fornecerá uma base sólida para os participantes que desejam interagir com a web, permitindo que façam requisições HTTP e consumam APIs com eficiência em Python, e lidem com respostas de maneira robusta e segura.
Conteúdo Programatico
Introduction to HTTP and Requests
- Overview of HTTP: Methods, status codes, headers, and body
- Why use the Requests library?
- Installing and setting up Python Requests
- First request: Making your first HTTP GET request
Making GET Requests
- Basic structure of a GET request
- Sending query parameters in a GET request
- Handling query strings and URLs dynamically
- Inspecting the response: Status codes, headers, and content
Making POST, PUT, DELETE Requests
- The difference between GET, POST, PUT, and DELETE
- Sending data via POST and PUT requests
- Uploading files in a POST request
- Sending JSON data in requests
- Deleting resources with a DELETE request
Handling HTTP Responses
- Understanding response status codes and their meanings
- Reading and parsing response content (JSON, XML, HTML)
- Handling binary responses (e.g., images, PDFs)
- Accessing response headers and metadata
- Extracting information from HTML with BeautifulSoup (optional integration)
Working with Headers and Authentication
- Adding custom headers to your requests
- Handling common HTTP authentication methods (Basic, Bearer tokens)
- Using API keys and tokens in requests
- Managing authentication with OAuth (brief introduction)
Handling Cookies and Sessions
- What are cookies and how they work in HTTP
- Managing cookies between requests
- Using the
Session
object in Requests for persistent sessions
- Making authenticated requests using sessions
Sending Data in Requests
- Sending form-encoded data (application/x-www-form-urlencoded)
- Sending multipart form data for file uploads
- Sending JSON payloads in requests
- URL encoding and decoding query parameters
Handling Timeouts, Redirects, and Errors
- Setting timeouts for HTTP requests
- Managing automatic redirects and how to control them
- Handling common exceptions in Requests (e.g., connection errors, timeouts)
- Retrying failed requests with backoff strategies
Advanced Requests Features
- Streaming large requests and responses
- Using proxies with Requests
- Handling SSL certificates and making secure requests
- Customizing the SSL/TLS behavior for secure connections
- Uploading files asynchronously with the
aiohttp
library (optional section)
Consuming APIs with Python Requests
- Introduction to REST APIs and how to interact with them
- Making GET and POST requests to public APIs
- Parsing and working with JSON responses
- Real-world example: Consuming a public API (e.g., GitHub, OpenWeatherMap)
Error Handling and Debugging Requests
- Catching and handling different HTTP exceptions
- Debugging requests using logging and verbose output
- Tools for inspecting HTTP requests (Postman, curl)
- Best practices for error handling in web requests
Practical Projects
- Building a Python script that interacts with a public API
- Automating a web-based task using Python Requests
- Implementing a simple web scraper with Requests and BeautifulSoup (optional)
Final Project: Building an API Consumer in Python
- Designing a Python application to consume and process data from multiple APIs
- Implementing error handling, logging, and retry mechanisms
- Parsing and saving API responses into a local database (optional)
- Deploying the script as an automated task or cron job