dimanche 6 septembre 2020

Python: Downloading an image from an URL but getting HTTP Error 403

I'm trying to download this image: https://bu3.mkklcdnbuv1.com/mangakakalot/m2/mother_im_sorry/chapter_5_chapter_5/2.jpg

I have tried: Set Headers = {'User-agent': 'Mozilla/5.0'}

The code i received is still 403.

Can anyone suggest me a way to overcome this?

My Code:

import requests
import shutil

r = requests.get('https://bu3.mkklcdnbuv1.com/mangakakalot/m2/mother_im_sorry/chapter_5_chapter_5/2.jpg',stream=True, headers={'User-agent': 'Mozilla/5.0'})
print (r.status_code)
if r.status_code == 200:
    with open("img.png", 'wb') as f:
        r.raw.decode_content = True
        shutil.copyfileobj(r.raw, f)



Aucun commentaire:

Enregistrer un commentaire