Note that there are some explanatory texts on larger screens.

plurals
  1. POPython mechanize - form submission - selecting the correct form
    primarykey
    data
    text
    <p>Trying to use Python mechanize to log in to a webpage. Since I have a problem with finding the correct form, instead of posting the URL (which the code might change) I will copy some of the code here for future users. I read <a href="https://stackoverflow.com/questions/8570920/submitting-forms-with-mechanize-python">this</a>, but there didn't seem too be a definitive answer.</p> <p>Anyways, I did everything with mechanize in <a href="http://stockrt.github.com/p/emulating-a-browser-in-python-with-mechanize/" rel="nofollow noreferrer">this tutorial</a> up until where I am getting the forms.</p> <p>When I call:</p> <pre><code>for form in br.forms(): print form </code></pre> <p>I get back:</p> <pre><code>POST https://www.myexample.com/x-www-form-urlencoded HiddenControl(utf8=✓) (readonly) HiddenControl(authenticity_token=BfqPL1ilOXeg08Or/CEBAiK4duWgncY= CheckboxControl(affiliate[remember_me]=[1]) </code></pre> <p>Looking at the raw HTML I see:</p> <pre><code>&lt;label for="affiliate_email"&gt;Email&lt;./label&gt; &lt;.input autofocus="autofocus" id="affiliate_email" name="affiliate[email]" size="30" type="email" /&gt; </code></pre> <p>However, when I try to select the email field I get a form not found error.</p> <pre><code>br.select_form(name="affiliate[email]") # updated to br.select_form(nr=0) # Now what do I do here to enter something into that form? br.form['someIDhere']='myEmail@example.com' </code></pre> <p>I have also tried using the form ID, and many other possible form names. I don't understand why printing the forms with br.forms() returns those strange results, does this mean the site is using javascript for login forms?</p> <p>Thank you in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload