# Login to lonked in is failing with Mechanize

**URL:** <https://www.ruby-forum.com/t/login-to-lonked-in-is-failing-with-mechanize/124400>\
**Category:** Ruby\
**Created:** [December 28, 2007, 11:27am UTC](https://www.ruby-forum.com/t/login-to-lonked-in-is-failing-with-mechanize/124400 "2007-12-28T11:27:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rita\_amritkar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cc9497/32.png) [@rita\_amritkar](https://www.ruby-forum.com/u/rita_amritkar)\
**Post date:** [December 28, 2007, 11:27am UTC](https://www.ruby-forum.com/t/login-to-lonked-in-is-failing-with-mechanize/124400/1 "2007-12-28T11:27:18Z")

</div>

Hi all,

I am trying to login to linked in but it is failing with Mechanize.  
code is,

agent = WWW::Mechanize.new  
page = agent.get(“[https://www.linkedin.com](https://www.linkedin.com)”)  
link = page.links.find {|l| l.text =~ /Sign in/}  
page = agent.click(link)  
form = page.forms.first  
form.fields.find {|f| f.name == “session\_login” }.value = “linkedin\_id”  
form.fields.find {|f| f.name == “session\_password” }.value = “password”  
page = agent.submit(form, form.buttons.first)  
puts page.body

I am getting the same sign in page.

What can be wrong with this piece of code?  
Any help will be appreciated.

Thanks in advance.
