Home > database >  Rendering an image with requests without saving the image
Rendering an image with requests without saving the image

Time:01-03

I have a code which which fetches company logos from clearbit API. Please find the code below:


url = "https://logo.clearbit.com/shopify.com"

payload={}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

I need to render it as an image instead of text. Please help me

CodePudding user response:

An image is binary data. You will find the following solution in the documentation.

url = 'https://logo.clearbit.com/shopify.com'
resp = requests.get(url)
resp.raise_for_status()
data = resp.content
  • Related