Requests module with urllib

Viewed 9

What's the best way to replace requests module code with urllib?


import boto3
import requests

# This function capitalizes all text in the original object
def lambda_handler(event, context):
    
    object_context = event["getObjectContext"]
    # Get the presigned URL to fetch the requested original object 
    # from S3
    s3_url = object_context["inputS3Url"]
    
    # Get the original S3 object using the presigned URL
    response = requests.get(s3_url)
    original_object = response.content.decode("utf-8")
0 Answers
Related