0

我正在编写一个脚本来自动为我提交表单。我得到了一切工作,但我不能让它提交表格。我认为这与每个领域都有以下事实有关:

style=display: none;

所以,这可能是它不提交的原因。

这是我所拥有的:

import mechanize
#coding=utf-8
br = mechanize.Browser()
br.set_handle_robots(False)
resp = br.open('http://support.twitter.com/forms/dmca')
#print resp.get_data()
formcount=0
submitcount=0
for form in br.forms():

       if str(form.attrs["id"]) == "dmca_form":
          break
       formcount=formcount+1
       br.select_form(nr=formcount)


form['submission_type'] = ['represent']
copyright_owner = form.find_control(id="copyright-owner")
copyright_owner.value = 'Steve Jobs'



fullname = form.find_control(id="fullname_input_text")
fullname.value = 'Rob William'
company = form.find_control(id="company")
company.value = 'Abc LLC'
job = form.find_control(id="job")
job.value = 'CEO'
email = form.find_control(id="email")
email.value = 'stevejobs@aol.com'
address=form.find_control(id="address")
address.value = '1600 Penn. Ave NW'
city=form.find_control(id="city")
city.value='Washington'
state=form.find_control(id="state")
state.value='DC'
postal=form.find_control(id="postal")
postal.value='20050'
country=form.find_control(id="country")
country.value='United States'
#form['inf_type']=['tweet','image']
form['inf_type']=['tweet']
form['tweet_account_1']='Obama12Fan' #@accountname
form['tweet_original_1']='please disregard this.' #Description of Work
form['tweet_infringement_1']='please disregard this.' #Description of Infringement
form['tweet_url_1']='https://twitter.com/BrooklynInsides/status/272763973022134272' #URL of Tweet
form['tweet_target_1']=['website']
form['tweet_website_direct_1']=['1']
form['tweet_website_direct_confirm_1']=['on']
#form.find_control("tweet_website_direct_confirm_1").items[0].selected=True

form['statement_1']=['I understand that under 17 U.S.C. § 512(f), I may be liable for any damages, including costs and attorneys’ fees, if I knowingly materially misrepresent that reported material or activity is infringing.']
form['statement_2']=['I have good faith belief that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law.']
exact=form.find_control(id="exact_match_input")
exact.value='The information in this notification is accurate, and I state under penalty of perjury that I am authorized to act on behalf of the copyright owner.'
Signature=form.find_control(id="fullname_input")
Signature.value='Rob William' #Must match full name as above




#submit = form.find_control(id="submit_button")
#br.submit(submit)

req = form.click(id="submit_button")
#print mechanize.urlopen(form.click(id="submit_button")).read()
#br.open(req)
#print br.response().read()

print br.response().read()

#print form

#save to a file
#f = file('myfile.html', 'w')
#f.write(br.response().read())
#f.close()
4

0 回答 0