Forum: Ruby Mechanize and Cookies

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Patrick H. (Guest)
on 2006-05-12 22:47
(Received via mailing list)
I am trying to access some google stuff (summer of code :-) which
requires that I am signed in - when I run the code below it says "Your
browser's cookie functionality is turned off. Please turn it on"

Mechanize seems to support cookies, but I must be doing something wrong.

Thanks
pth

--------------------------------------------------

require 'mechanize'

agent = WWW::Mechanize.new {|a| a.log = Logger.new(STDERR) }
page = agent.get('http://www.google.com/')

link = page.links.text(/sign\s*in/i).first
page = agent.click(link)
form = page.forms[0]

email = form.fields.find { |f| f.name =~ /email/i }
email.value = 'email addr'
passwd = form.fields.find { |f| f.name =~ /passwd/i }
passwd.value = 'pass word'

submit = form.buttons.find { |b| b.value =~ /sign\s*in/i }
page = agent.submit(form, submit)
puts page.body
Aaron P. (Guest)
on 2006-05-13 10:22
(Received via mailing list)
On Sat, May 13, 2006 at 03:46:32AM +0900, Patrick H. wrote:
> I am trying to access some google stuff (summer of code :-) which
> requires that I am signed in - when I run the code below it says "Your
> browser's cookie functionality is turned off. Please turn it on"
>
> Mechanize seems to support cookies, but I must be doing something wrong.
>

[snip]

Hey Patrick, it doesn't look like you were doing anything wrong.  It
looks like google doesn't send a space after semicolons in the
'Set-Cookie' string, and the cookie parser couldn't handle that.  I
fixed the problem, and it should be available in the next release.  If
you need it before that, just check out the current release branch:

svn co svn://rubyforge.org/var/svn/mechanize/branches/RB-0.4.5

and build the gem:

rake package

If you run in to any troubles, just send mail to the mechanize-devel
list:

http://rubyforge.org/mail/?group_id=1453

HTH

--Aaron
Patrick H. (Guest)
on 2006-05-13 15:46
(Received via mailing list)
On 5/13/06, Aaron P. <removed_email_address@domain.invalid> wrote:
> Hey Patrick, it doesn't look like you were doing anything wrong.  It
>
>
Thanks so much
pth
This topic is locked and can not be replied to.