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

Sign Up Forgot your password?

the log file of the connection :

On Fri, Oct 17, 2014 at 9:02 PM, Olivier M. [email protected]
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’)
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…

title=“username” tabindex=“4” type=“text”>



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:

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’) 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 [email protected]:

above and below, but set the user agent alias on an instance variable
Maybe check agent.current_page at this point, as well? It should be the

      <span class="signinq">
      <a class="forgotpassword" href="

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:


Cordialement

Olivier M.