I need to log in to a site to run some scripts. Mechanize with Nokogiri looks perfect for the task, but I’m having a hard time inputting the login information since the input fields aren’t located in forms (agent.page.forms.first yields nil):
<div class="loginform" id="login_form">
<div>
<input type="text" id="loginname" tabindex="1"/>
</div>
<div>
<input type="password" id="password" tabindex="2"/>
<input type="text" id="password_text" style="display:none;"/>
</div>
<div class="signin"><a href="javascript:void(0);" class="sp" id="login_submit_btn"></a>
</div>
</div>
Is it possible to somehow navigate to the input elements (they’re the only ones on the page) and then submit my username and password to log in? If Mechanize isn’t capable of doing something like this, are there alternatives? Thanks so much.
I think you would better check inside the whole source (including javascript) how the website connect you.
It should be a HTTP POST request in my opinion… and use it to log directly without parsing the main page by GET request but using
Mechanize post methodinstead :Hope it helps too.