python - Capture Automatic Downloads using Mechanize -


we have new vendor being pain helping data our warehouse. unwilling provide feed, , need process automated. don't have access servers data lives, there reporting portal. i'm looking download , store xls files portal scraping mechanize. have setup logging in , filling out form spits out xls, issue it's automatic download(once fill out report selection , dates, download automatically starts). know how can python?

the code may not matter since below works properly, don't know how go saving data.

import mechanize import cookielib

import mechanize import cookielib  cj = cookielib.cookiejar() br = mechanize.browser() br.set_cookiejar(cj) #open login page br.open("https://example.com/login/login") #select form br.select_form(nr=0) br.form['username'] = 'xxx' br.form['password'] = 'xxx' br.submit() #open reporting portal page br.open('https://example.com/policy/app/reports?execution=e1s1') br.select_form(nr=0) br.form['form1:j_idt35'] = ['policytransactions.jrxml'] br.submit() #select first part of form. these fields hidden until value first field supplied br.select_form(nr=0) br.form['form1:datefield3_input'] = '01012017' br.form['form1:datefield4_input'] = '02012017' br.select_form(nr=0) print br.form 


Comments