Image URL is not downloading

Question:

I am trying to download an image from a website but it’s not working, however it worked on Postman.

import requests

url = "https://www.sephora.com/productimages/sku/s1557941-main-zoom.jpg?imwidth=2000"

payload = {}
headers = {
    'User-Agent': 'Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 108.0.0.0 Safari / 537.36'
}

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

print(response.text)  

What I am missing, tried adding some headers but nothing worked.

Asked By: Kiran B Chitari

||

Answers:

Your user agent value is malformed -> missing space after 5.0. Once you correct that it should be working fine:

headers = {
    'User-Agent': 'Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 108.0.0.0 Safari / 537.36'
}
Answered By: Marcin Orlowski