mardi 6 mars 2018

Download a compressed zip file from URL using Python3.6

I am new to Python programming. I have a problem statement where I have to login to a website and then download a zip file. I have written the below code so far to login to website(able to print authentication successful message) and create a session. How can I download the zip file now ?

I am using python 3.6

Any help is much appreciated. Thanks !

import requests
import urllib
import urllib.request
import zipfile
import io
import shutil

post_login_url = 'https://www.ims-dm.com/mvc/page/customer-sign-in/cgi/cookie.php' 
request_url = 'http://www.ims-dm.com/cgi/securedownload.php?p=WPNFTPD#prodtype=wpn/WPN-FULL-20180306.TXT.zip'

payload = { 
         'sendusername':'xxxxxxxxxx', 
         'password':'xxxxxx'
} 

with requests.Session() as session:
    post = session.post(post_login_url,data=payload)    
    if post.status_code == 200:
        print("Authentication sucessful !!")
        url = session.get(request_url)




Aucun commentaire:

Enregistrer un commentaire