Wednesday 15 July 2015

http - How to submit a form with more than 1 submit button. Sending a POST to a website. (Python) -


I am using a script that can log on to a website and submit a form. However, there are 3 submit buttons (preview, post, and cancel) in this form. I'm only using one button ...

This form is:

  & lt; TextControl (subject =) is it good for the holidays? New technology?) & Gt; & Lt; IgnoreControl (thread = & lt; no & gt;) & gt; & Lt; TextareaControl (Message = New to Technology shares.) & Gt; & Lt; SelectControl (identity = [* annamae41g]) & gt; & Lt; Radiocontrol (E = [5, 4, * 3, 2, 1, 0]) & gt; & Lt; SubmitControl (Submit Preview = Preview Message) (Read Only) & gt; & Lt; SubmitControl (Submit Submit = Post Message) (Read Only) & gt; & Lt; SubmitControl (SubmitCancel = Cancel) (Read Only) & gt; & Lt; Hidden Controls (Action_btn =) (Read Only) & gt; & Lt; Hidden controls (_charset_ =) (read only) & gt; & Lt; Hidden Controls (.crumb = 4DxnFEwMIGG) (Read Only) & gt; & Lt; Hidden controls (R = / stock_ (A_to_Z) / stocks_g) (Read Only) & gt; & Lt; Hidden Controls (BN = 25263) (Read Only) & gt; & Lt; Hidden Controls (& lt; None; = annamae41g) (Read Only) & gt; & Gt;  

And this is my code:

  br.open (newtopic_url) br.select_form (name = "postmsg") br.form ['subject' ] = "Is it good for the holidays? Anyone knows about new technology?" Br.form ['message'] = "IM technology is new in stock." Br.form ['e'] = ['3'] br.form ['identity]] = [' annamae41g '] print br.form br.submit ()  

if i Run this script ... it will not work. Nothing happened. I'm assuming because there are 3 submit buttons in it? Or is it another issue?

I had problems similar to yours.

First, Mechanize was using only the first button, could see me using the answer to the server

 . Feedback = Browser.Submit () Print feedback. Reid ()  

To submit the mechanic function, enter the submit button name as the parameter, and it worked!

  response = browser.submit ("submit")  

Test it, it should work for you too!


No comments:

Post a Comment