Why does signing in with Mechanize

I'm trying to connect automaticaly to a website using Mechanize.

I read searched the internet but I can't find any solution to my problem,
which is why when i write nothing in, value = "", I get *Incorrect Login or
Password * but when i write my password i get nothing ?

agent = Mechanize.new{ |a| a.log = Logger.new("mech.log") }
@agent.user_agent_alias = 'Linux Firefox'
login_page = agent.get('http://xxxx.org/?op=my_files')
   login_form = login_page.forms.first
   login_field = login_form.field_with(*name: "login"*).value = "MyLogin"
   password_field = login_form.field_with(*name: "password"*).value =
"MyPassword"
     home_page = login_form.submit
     puts home_page.content

the code HTML

<div id="signincontainer">
        <form method="POST" action="http://xxx.org/" name="FL" id="signin">
          <input name="op" value="login" type="hidden">
          <input name="redirect" value="" type="hidden">
          <span class="signinq">
          <input style="background: url('images/username.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="username" *name="login"*
title="username" tabindex="4" type="text">
          <a class="donthaveaccount" href="http://xxxx.org/signup.html
"><span>
          Sign Up
          </span></a> </span> <span class="signinq">
          <input style="background: url('images/password.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="password" *name="password*"
value="" title="password" tabindex="5" type="password">
          <a class="forgotpassword" href="http://xxxx.org/forgot-pass.html"
id="resend_password_link"><span>
          Forgot your password?
          </span></a> </span>
          <input id="signin_submit" value="Enviar" tabindex="6"
src="images2/signin.png" type="image">
        </form>
      </div>

the log file of the connection :

···

--

I'm trying to connect automaticaly to a website using Mechanize.

I read searched the internet but I can't find any solution to my problem,
which is why when i write nothing in, value = "", I get *Incorrect Login
or Password * but when i write my password i get nothing ?

I can't say for sure what's going on here.

I do notice this:

agent = Mechanize.new{ |a| a.log = Logger.new("mech.log") }
@agent.user_agent_alias = 'Linux Firefox'

Is agent an attr_accessor or something? You've used a bare word 'agent'
above and below, but set the user agent alias on an instance variable
'@agent'.

login_page = agent.get('http://xxxx.org/?op=my_files&#39;\)
   login_form = login_page.forms.first
   login_field = login_form.field_with(*name: "login"*).value = "MyLogin"
   password_field = login_form.field_with(*name: "password"*).value =
"MyPassword"
     home_page = login_form.submit
     puts home_page.content

Maybe check agent.current_page at this point, as well? It *should* be the
same as home_page, but...

the code HTML

<div id="signincontainer">
        <form method="POST" action="XXX Sex - Free Porn Videos at XXX.com; name="FL"
id="signin">
          <input name="op" value="login" type="hidden">
          <input name="redirect" value="" type="hidden">
          <span class="signinq">
          <input style="background: url('images/username.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="username" *name="login"*
title="username" tabindex="4" type="text">
          <a class="donthaveaccount" href="http://xxxx.org/signup.html
"><span>
          Sign Up
          </span></a> </span> <span class="signinq">
          <input style="background: url('images/password.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="password" *name="password*"
value="" title="password" tabindex="5" type="password">
          <a class="forgotpassword" href="http://xxxx.org/forgot-pass.html&quot;
id="resend_password_link"><span>
          Forgot your password?
          </span></a> </span>
          <input id="signin_submit" value="Enviar" tabindex="6"
src="images2/signin.png" type="image">
        </form>
      </div>

the log file of the connection :
mechanize.log · GitHub

From the log, it certainly looks like it succeeded.

I have a similar sort of thing in one of my scrapers at:

···

On Fri, Oct 17, 2014 at 9:02 PM, Olivier Morel <oliviermo75@gmail.com> wrote:

How can i check i'm logged on the web site ?
Because if i write anything in my variable login i get this in the log

*LOG:*

D, [2014-10-20T16:35:22.507210 #8913] DEBUG -- : request-header:
content-length => 52
I, [2014-10-20T16:35:24.660472 #8913] INFO -- : status:* Net::HTTPOK 1.1
200 OK*
D, [2014-10-20T16:35:24.660576 #8913] DEBUG -- : response-header: server =>
nginx/1.6.0
D, [2014-10-20T16:35:24.660617 #8913] DEBUG -- : response-header: date =>
Mon, 20 Oct 2014 14:35:24 GMT
D, [2014-10-20T16:35:24.660653 #8913] DEBUG -- : response-header:
content-type => text/html; charset=UTF-8
D, [2014-10-20T16:35:24.660688 #8913] DEBUG -- : response-header:
transfer-encoding => chunked
D, [2014-10-20T16:35:24.660722 #8913] DEBUG -- : response-header:
connection => keep-alive

*CODE:*

*mechanize = Mechanize.new{ |a| a.log = Logger.new("mech.log") }
mechanize.user_agent_alias = "Linux Firefox" login_page =
mechanize.get('http://xxxxxx.org/?op=my_files
<http://xxxxxx.org/?op=my_files&gt;&#39;\) current_page = login_page.forms.first
    login_field = current_page.field_with(name: "login").value ="XXXX"
login_field = current_page.field_with(name: "password").value =
"XXXXX@1064" home_page = current_page.submit*

···

2014-10-18 9:25 GMT+02:00 tamouse pontiki <tamouse.lists@gmail.com>:

On Fri, Oct 17, 2014 at 9:02 PM, Olivier Morel <oliviermo75@gmail.com> > wrote:

I'm trying to connect automaticaly to a website using Mechanize.

I read searched the internet but I can't find any solution to my problem,
which is why when i write nothing in, value = "", I get *Incorrect Login
or Password * but when i write my password i get nothing ?

I can't say for sure what's going on here.

I do notice this:

agent = Mechanize.new{ |a| a.log = Logger.new("mech.log") }
@agent.user_agent_alias = 'Linux Firefox'

Is agent an attr_accessor or something? You've used a bare word 'agent'
above and below, but set the user agent alias on an instance variable
'@agent'.

login_page = agent.get('http://xxxx.org/?op=my_files&#39;\)
   login_form = login_page.forms.first
   login_field = login_form.field_with(*name: "login"*).value = "MyLogin"
   password_field = login_form.field_with(*name: "password"*).value =
"MyPassword"
     home_page = login_form.submit
     puts home_page.content

Maybe check agent.current_page at this point, as well? It *should* be the
same as home_page, but...

the code HTML

<div id="signincontainer">
        <form method="POST" action="XXX Sex - Free Porn Videos at XXX.com; name="FL"
id="signin">
          <input name="op" value="login" type="hidden">
          <input name="redirect" value="" type="hidden">
          <span class="signinq">
          <input style="background: url('images/username.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="username" *name="login"*
title="username" tabindex="4" type="text">
          <a class="donthaveaccount" href="http://xxxx.org/signup.html
"><span>
          Sign Up
          </span></a> </span> <span class="signinq">
          <input style="background: url('images/password.png') no-repeat
scroll 5px 50% rgb(255, 255, 255);" id="password" *name="password*"
value="" title="password" tabindex="5" type="password">
          <a class="forgotpassword" href="
http://xxxx.org/forgot-pass.html&quot; id="resend_password_link"><span>
          Forgot your password?
          </span></a> </span>
          <input id="signin_submit" value="Enviar" tabindex="6"
src="images2/signin.png" type="image">
        </form>
      </div>

the log file of the connection :
mechanize.log · GitHub

From the log, it certainly looks like it succeeded.

I have a similar sort of thing in one of my scrapers at:
scrapers/lib/scrapers/manning_books.rb at master · tamouse/scrapers · GitHub

--
Cordialement

Olivier Morel