1

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.jgp", 'wb') as f:
        r.raw.decode_content = True
        shutil.copyfileobj(r.raw, f)
2
  • I even couldn't visit this page in the browser. Commented Sep 6, 2020 at 11:41
  • Oh. I realized if i paste that URL to browser, i can't access it, but i can if i go to mangakakalot and select a random chapter => open image in new tab then i can... Commented Sep 6, 2020 at 11:47

1 Answer 1

2

You need to set the referer header in your code, like:

import requests

with requests.Session() as session:
    resp_2 = session.get("https://bu3.mkklcdnbuv1.com/mangakakalot/m2/mother_im_sorry/chapter_5_chapter_5/2.jpg", headers={"referer":"https://mangakakalot.com/chapter/ro920198/chapter_5"})
    with open("xx.jpg","wb") as f:
        f.write(resp_2.content)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks alot! But how can i decode and save the content? I've tried: r.content.decode() but it didn't work...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.