Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a way around this be actually getting a non 401 response from the server.</p> <p>Firstly: Try this</p> <pre><code>for form in br.forms(): print "Form name:", form.name print form </code></pre> <p>the response looks like:</p> <pre><code>Form name: None &lt;POST http://portal.globaltransit.net/login application/x-www-form-urlencoded &lt;TextControl(signin[username]=)&gt; &lt;PasswordControl(signin[password]=)&gt; &lt;CheckboxControl(signin[remember]=[on])&gt; &lt;HiddenControl(signin[_csrf_token]=ec9a290dcc8d71e458d31a0fd509376b) (readonly)&gt; &lt;SubmitControl(&lt;None&gt;=sign in) (readonly)&gt;&gt; </code></pre> <p>Here you can see the actual url returned is a bit different than the url used in you code.</p> <p>Now do :</p> <pre><code>response = br.open("http://portal.globaltransit.net/login application/x-www-form-urlencoded") </code></pre> <p>the response is :</p> <pre><code>send: 'GET /login application/x-www-form-urlencoded HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: portal.globaltransit.net\r\nCookie: symfony=f6fa25cf26e310e7e8bb3170637fdd73\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1\r\n\r\n' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Tue, 26 Nov 2013 17:45:01 GMT header: Server: Apache header: X-Powered-By: PHP/5.2.11 header: Content-Length: 1211 header: Connection: close header: Content-Type: text/html; charset=utf-8 </code></pre> <p>The key here is to use the Url returned from the <strong>br.form</strong> name. Then you can go ahead and use the forms as usual. </p> <p>A good guide to do this can be found here <a href="http://www.pythonforbeginners.com/cheatsheet/python-mechanize-cheat-sheet/" rel="nofollow">http://www.pythonforbeginners.com/cheatsheet/python-mechanize-cheat-sheet/</a></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.
    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