我使用twill
在一个有登录表单保护的网站上进行导航。
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')
在最后一页,我想要下载一个Excel文件,可以通过以下属性的
访问:
使用
然而,返回的是对应于原始内容的字符串:因此无法使用。是否有一种类似于
onclick="OpenWindowFull('../util/exports/control.php?action=export','export',200,100);"
使用
twill
,我能够访问 PHP 脚本的 URL 并显示文件内容。go('http://www.example.com/util/exports/control.php?action=export')
show()
然而,返回的是对应于原始内容的字符串:因此无法使用。是否有一种类似于
urllib.urlretrieve()
的方式直接检索Excel文件?
twill
。(我更喜欢使用requests
,但似乎有一个复杂的控制登录头,并且经过多次尝试,我只能使用twill
使其正常工作)。 - Antoine Gautier