Reputation: 13
I'm trying to download this image programmatically using python.
The code snippet below works perfectly fine for any other url (image source). However, for this specific image I'm downloading some kind of security check page rather than the wanted image.
requests.get(url, stream=True).content
Entering the linked URL in e.g. postman downloads the picture. What is the difference with the get request I'm sending through postman and the one I'm sending programmatically?
Thanks a lot!
Upvotes: 0
Views: 55
Reputation: 3115
Postman probably uses a different user-agent than requests.
You can add a common browser user-agent to your request. Then no Cloudflare page is displayed to me.
requests.get(
url,
stream=True,
headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36'}
).content
Upvotes: 1