import re
import requests
import zipfile
import werkzeug
werkzeug.cached_property = werkzeug.utils.cached_property
from robobrowser import RoboBrowser
br = RoboBrowser(history=True)
br.open("loginurl")
forms = br.get_forms()
form=forms[0]
form['username'] = 'myname'
form['password'] = 'mypass'
br.submit_form(form)
url = "ulrlocationofzipfiledownload"
request = br.session.get(url, stream=True)
with open ('data.zip', 'wb') as f:
f.write(request.content)
As of now, this works and it downloads a zipfile (to my desktop where the script is located)
I want it to extract specific contents from the zipfile to a specific location without creating the zipfile on my desktop
I tried some variations of this code:
with zipfile.ZipFile('files.zip','r') as f:
myzipfile.extractall('files')
but I couldn't get it to work.
Is it possible to get zipfile from the web and extract some of its specific contents to a specific locations on PC, all without saving the downloaded zipfile first (maybe only keeping the zipfile "open" in RAM ?)