我想知道是否有人有关于如何提交两次的提示?我可以验证它是否正在提交表单,但我需要在以下确认页面上再次提交。这可能吗?
br = mechanize.Browser()
br.open("http://internal/test/stopservice.cfm")
br.select_form(nr=0)
br.form['Account_number'] = 'Enter your Name'
br.form['Name_first_account'] = 'Enter your Title'
br.form['Name_last_account'] = 'Enter your message'
br.form['Address_House_Number_stop'] = 'Enter your message'
br.form['Address_Direction_Prefix_stop'] = ['E']
br.form['Address_Street_stop'] = 'Enter your message'
br.form['City_stop'] = 'Enter your message'
br.form['State_stop'] = ['IL']
br.form['Zip_mail_stop'] = '60062'
br.form['E_mail'] = 'test@gmail.com'
br.form['Requester_Type'] = ['Tenant']
br.form['confirm_email'] = 'Enter your message'
br.form['Phone_Contact_1'] = '111'
br.form['Phone_Contact_2'] = '555'
br.form['phone_Contact_3'] = '9999'
br.form['MM_stop'] = ['09']
br.form['DD_stop'] = ['22']
br.form['YYYY_stop'] = ['2017']
br.find_control("Turn_off_Gas").items[0].selected=True
br.submit()
答案 0 :(得分:0)
我想你可以这样做:
#!/usr/bin/env python
import mechanize
url = "..."
def on_start(url):
br = mechanize.Browser()
br.open(url)
return br
def sub_form(br):
br.select_form(nr=0)
br.form['Account_number'] = 'Enter your Name'
# other options....
new_url = br.submit()
# retrieve the new url after submiting the form
br.open(new_url.geturl())
# complete the new form
br.select_form(nr=...)
# other options here
br.submit()
# initialize the browser
browsr = on_start(url)
sub_form(browsr)