本文整理汇总了Python中mechanize.Browser.form['start_year']方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.form['start_year']方法的具体用法?Python Browser.form['start_year']怎么用?Python Browser.form['start_year']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mechanize.Browser
的用法示例。
在下文中一共展示了Browser.form['start_year']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from mechanize import Browser [as 别名]
# 或者: from mechanize.Browser import form['start_year'] [as 别名]
get_files = list(set(get_files) - set(exclude))
# create a list of end_year values
control = form.find_control('end_year', type='select')
end_year = []
for item in control.items:
end_year.append(item.name)
# export and save each report type
for item in get_files:
# need to navigate back to export page after each iteration
br.open(EXPORT_URL)
br.select_form(nr=0)
# ListControl, must set a sequence
br.form['start_year'] = ['1900', ]
br.form['end_year'] = [end_year.pop(), ]
br.form['type'] = [item, ]
response = br.submit()
# extract file name from headers
headers = response.info()
fname_start = headers['Content-Disposition'].find('"')
fname_end = headers['Content-Disposition'].find('.', fname_start)
fname = headers['Content-Disposition'][(fname_start + 1):fname_end]
data = response.read()
print 'Now downloading... ' + fname
# write the file with today's date stamp
DEST_FILE = save_path + 'NAVIANCE_' + fname + '.csv'
# for keeping a running record of files + '_' + datetime.now().strftime('%Y%m%d')