Lonny Eachus | 29 Mar 2011 19:18
Picon

Re: LinkedIn still not working?


No, the problem is as I stated.

It does indeed redirect, but to the wrong place: I end up on a redirect page, but the link is back to the home
(landing) page, not the user page it should go to. It appears that Mechanize is NOT successfully logging
in, for whatever reason, precisely as described in the link I first gave.

At least that is the appearance of things... it might be failing for a different reason but it is still
failing, and trying to redirect me to the landing page ("http://www.linkedin.com/home") rather than
the user's home page ("http://www.linkedin.com/nhome").

If anybody has an answer, I would really appreciate it. It it important for me to do this, and I have been
pulling my hair.

Lonny Eachus
============

> ------------------------------
> 
> Message: 7
> Date: Tue, 29 Mar 2011 09:53:28 -0400
> From: Benjamin Manns <benmanns <at> gmail.com>
> To: Ruby Mechanize Users List <mechanize-users <at> rubyforge.org>
> Subject: Re: [Mechanize-users] LinkedIn still not working?
> Message-ID:
> 	<AANLkTikg4qKN0Gttf=OkvuR8wJXtx-Td5fN49EnEuUPy <at> mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Lonny,
> 
(Continue reading)

Lonny Eachus | 28 Mar 2011 00:00
Picon

Re: LinkedIn still not working?


To clarify the issue I posted earlier:

I am on OS X 10.6.7.  Trying to use Mechanize to log in to LinkedIn. As others have posted about in the past, when I submit the form it kicks me back to the LinkedIn landing page, and does not log me in.

I read the earlier discussion of the issue that mentioned how cookie values were being improperly dequoted when stored. But I thought that issue was fixed. I tried manually entering quotes back in to the cookie values, but so far that hasn't worked for me.

I am able to log in just fine using Watir, so I have to assume that this is some kind of javascript or cookie issue. I would really rather use mechanize here because in the particular app I am working on, Watir would be something of a burden.

Here is the code I was using (minus adding quotes to cookies), which I modified from the discussion I found here: http://bit.ly/e6J38E 


     require 'rubygems' if VERSION < '1.9'
     require 'open-uri'
     require 'nokogiri'
     require 'mechanize'

     agent = Mechanize.new
     agent.read_timeout = 300
     agent.open_timeout = 60
     agent.max_history = 1 # Prevent excessive memory usage
     agent.user_agent_alias = 'Mac Safari'

     page = agent.get(https://www.linkedin.com/secure/login?trk=hb_signin)

     form = page.form('login')
     form.session_key = USERNAME
     form.session_password = PASSWORD
     new_page = form.click_button


Any help would be appreciated.

Lonny Eachus
============
_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
m_takao | 23 Feb 2011 14:30
Picon

a strange RedirectLimitReachedError

Hello.
I tried to get "http://www.amazon.co.jp/dp/B001WAL592" with Mechanize,
but RedirectLimitReachedError occurred.
with TCPSocket, server returned 200 OK and Location was not found in header.
It seems Mechanize's bug.

ruby 1.8.7
mechanize 1.0.0
thomas@randspringer.de | 21 Feb 2011 16:11
Picon

redirect ignored?

Hi,

 

I'm doing my first steps with

 

cucumber (0.10.0)

webrat (0.7.3)

mechanize (1.0.0) 

 

under rails (3.0.4).

 

As a first test I tried to check our login dialog. It worked basically (I see the successful login procedure in the server.log) but after a successfully login the user is redirected to

 

  "redirect_to root_url" in the rails code.

 

And there I get an error in my cucumber test:

 

>snip

 ...

 You are being redirected. (RSpec::Expectations::ExpectationNotMetError)

>snip

 

I found this patch suggestion:

http://www.42.mach7x.com/2011/01/03/webrat-0-7-2-problem-with-rails-3-0-3/

but it did not help.

 

My workaround is now that I do a

"visit root_url"

before I

"response_body.should contain(welcome)"

 

but the first line should not be necessary.

 

Any help available?

 

Thomas

 

 

 

 

 

 

_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
Alex | 18 Jan 2011 08:37
Picon
Gravatar

how to get captcha image with mechanize ?

Hey, how to get captcha image with mechanize ? the image is not a static picture, it's a stream, a text-model.
_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
Cindy Schaller | 23 Dec 2010 04:13
Picon

Multi-Step forms with Mechanize

Hi,

 

I need to fill out a multi-page form using Mechanize and am trying to figure out how to step through the pages to get back the final results. 

 

I’ve tried a few different variations, but can’t get any of them to work.  This is the most recent variation.  The first submit works well, but then I am unable to figure out how to access and submit the form on the following page.  Any help is greatly appreciated!!!!

 

 

agent.get(data) do |data|

  data.form('Page1') do |data_type|

    data_type.field("A").option_with(:value => '1').select

    # pp data_type # this verifies that the select option is selected

  end.submit

 

   # ??? The previous submit presents me with another form and I need to select more variables and hit submit again.

 

end

 

Thanks,

Cindy

 

_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
深谷 芳和 | 16 Dec 2010 23:41
Picon

ruby1.9.2

Can mechanize work with ruby1.9.2?

iPhoneから送信
Abel Muiño Vizcaino | 26 Oct 2010 15:18
Picon
Gravatar

Infinite loop on meta refresh

Hi!

I have a problem when using Mechanize as a crawler with some pages which have long-delayed meta refresh to the same url.

First, some context: I want to reach "the real thing" when navigating to urls with delays... so following all kind of redirects (including meta refresh) is on my whishlist.

What I have found is that pages such as TechMeme have a meta refresh to the same URL with very long waits (1800 seconds). For these pages it takes too long to reach the maximum number of redirects (and there is no real value in following the redirects either).

For theses situations, it is not clear what the best option is, since several factors are at play.

I would propose having a flag which avoids redirecting (and waiting) when the refresh is to the same url. This would be off by default allowing other use cases.

Other option that could be useful for a wider range of use cases is ignoring waits on meta refresh.

This is summarized also as an issue on github: http://github.com/tenderlove/mechanize/issues/issue/67

I am very new to Mechanize and I might be abusing it :-). Or just not seeing a better way of handling this.

So, before I embark in forking & everything... feedback on this issue is welcome!
--
Abel Muiño
_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
Hosein Shafiei | 21 Oct 2010 00:00
Picon

Mechanize::ResponseCodeError: 500

_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
overco | 20 Oct 2010 19:12

Scrape data from AdWords

http://www.skyrocketonlinemarketing.com/2010/06/20/scrape-ppc-spend-data-from-adwords-with-ruby-mechanize/

Jonathan Clarke — Campaign Manager
U365
Cell Number: +1-246-256-0770
Skype IM Chat: jonathan.clarke

This message is intended only for the addressee and contains privileged and
confidential information.  If you have received this message in error please
notify me immediately and delete the original message and destroy any copies
of it.

_______________________________________________
Mechanize-users mailing list
Mechanize-users <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/mechanize-users
Gazizov Andrey | 20 Oct 2010 12:04
Gravatar

HTTP POST request using Mechanize

Hello guys,

I'm newbie in ruby and Mechanize. I has created a script to make a POST 
and GET HTTP request to Redmine application. So, everything fine with 
GET request and authorization. But when I try to do a POST request 
Mechanize gave a following error:

ws-moonshiner# ruby post.rb
/usr/local/lib/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:464:in 
`post_form': 500 => Net::HTTPInternalServerError 
(Mechanize::ResponseCodeError)
	from 
/usr/local/lib/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:357:in 
`post'
	from post.rb:21

Here is my script:

require 'rubygems'
require 'mechanize'
require 'logger'

# runnig a Mechanize
agent = Mechanize.new { |a| a.user_agent_alias = 'Mac Safari'}

agent.log = Logger.new(STDOUT)

# get the Redmine login form & fill it out with the username/password
page = agent.get("http://127.0.0.1/login")
login_form = page.form_with(:action => "/login")
login_form.username = 'test'
login_form.password = 'test'

# submit Redmine login form
page = agent.submit login_form

issues_page = agent.get("http://127.0.0.1/projects/test/issues")

agent.post(issues_page, {
   "priority_id" => "3",
   'tracker_id' => "1",
})

Latest message from logger:
[...]
I, [2010-10-20T13:56:00.340095 #16626]  INFO -- : status: 500

I understand that for some reason server generates an internal error. 
But I have no idea how to fix it. Does anybody know how to resolve this 
issue?

Thank you very much in advance.
--

-- 
Best regards,
Andrew

Gmane