I use twill
to navigate on a website protected by a login form.
from twill.commands import *
go('http://www.example.com/login/index.php')
fv("login_form", "identifiant", "login")
fv("login_form", "password", "pass")
formaction("login_form", "http://www.example.com/login/control.php")
submit()
go('http://www.example.com/accueil/index.php')
On this last page I want to download an Excel file which is accessible through a div
with the following attribute:
onclick="OpenWindowFull('../util/exports/control.php?action=export','export',200,100);"
With twill
I am able to access the URL of the PHP script and show the content of the file.
go('http://www.example.com/util/exports/control.php?action=export')
show()
However a string is returned corresponding to the raw content: thus unusable. Is there a way to retrieve directly the Excel file in a way similar to urllib.urlretrieve()
?