小编hok*_*e85的帖子

python mechanize - 从aspnetForm submitControl检索一个文件,触发文件下载

当我不知道文件URL或文件名时,如何使用python mechanize从aspnetForm submitControl中检索触发Excel文件下载的文件?

带Excel文件的网站网址:http://www.ncysaclassic.com/TTSchedules.aspx?tid = NCFL&year = 2012& stid = NCFL&yearar = 2012&div = U11M01

我正在尝试通过Print Excel'按钮'下载文件.

到目前为止,我有:

r = br.open('http://www.ncysaclassic.com/TTSchedules.aspx?tid=NCFL&year=2012&stid=NCFL&syear=2012&div=U11M01')
html = r.read()

# Show the html title
print br.title()

# Show the available forms
for f in br.forms():
    print f

br.select_form('aspnetForm')
print '\n\nSubmitting...\n'
br.submit("ctl00$ContentPlaceHolder1$btnExtractSched")

print 'Response...\n'
print br.response().info()
print br.response().read

print 'still alive...\n'

for prop, value in vars(br.response()).iteritems():
    print 'Property:', prop, ', Value: ', value

print 'myfile...\n' 

myfile = br.response().read
Run Code Online (Sandbox Code Playgroud)

我得到这个输出:

    Submitting...

    Response...

Content-Type: …
Run Code Online (Sandbox Code Playgroud)

python file mechanize download

5
推荐指数
1
解决办法
1958
查看次数

标签 统计

download ×1

file ×1

mechanize ×1

python ×1