so, i've seen many different posts around here but nothing answered to all of my problems.. i am trying to download an image from a website, but in order to do so, I have to login to it. I have the Username (email) and password, and the image link. problem is, i tried 4-5 different scripts and none worked.. some used urllib which couldn't log in (resulted with the image saying "You are not logged in"), some used Requests which.. i actually don't know if it even saved the image because the image I recieved was corrupted or.. i dont know.. basically the image i was supposed to recieve is 41.2 kb and the corrupt image i recieved was 12 kb.. so thats that.. what i'm currently using, i deleted the email and password and changed the links..
from requests import Session
import shutil
import urllib
block=874
page=1
url1='http://website.com/images/blocks/%s/%s.png'%(str(block),str(page))
url = 'https://website.com/login.php'
s = Session()
s.post(url, {"password":"12345678", "email":"derpty@derp.com", "status":""})
res=s.get(url1,stream=True)
with open('img.png','wb') as out_file:
res.raw.decode_content = True
out_file.write(res.content)
del res
now I'm really new to this thing.. I don't even know if all i posted here is supposed to work or not.. well I guess that's why i'm posting here.. Thanks in advance!