Forum: Ruby How to get the cookie from a website?

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.
10957dc0546275790a8bd68d4cb9356a?d=identicon&s=25 song yangyang (songyangyang)
on 2013-04-15 11:53
Recently,I am confused that how to get cookie from a website.I installed
Mechanize,but don't know how to use it.need help.
0dfd10ad198ae5a87640da046a77a90a?d=identicon&s=25 Robert Jackson (Guest)
on 2013-04-15 14:37
(Received via mailing list)
On Apr 15, 2013, at 5:53 AM, song yangyang <lists@ruby-forum.com> wrote:

> I am confused that how to get cookie from a website.

Mechanize does keep track of the cookies that are set during various
requests.

Quick example:

```
require 'mechanize'

agent = Mechanize.new
agent.get 'https://google.com'
p agent.cookies
```

A few resources:

http://mechanize.rubyforge.org/
http://mechanize.rubyforge.org/Mechanize/CookieJar.html
http://mechanize.rubyforge.org/Mechanize/Cookie.html
E088bb5c80fd3c4fd02c2020cdacbaf0?d=identicon&s=25 "Jesús Gabriel y Galán" <jgabrielygalan@gmail.com> (Guest)
on 2013-04-15 14:38
(Received via mailing list)
On Mon, Apr 15, 2013 at 11:53 AM, song yangyang <lists@ruby-forum.com>
wrote:
> Recently,I am confused that how to get cookie from a website.I installed
> Mechanize,but don't know how to use it.need help.

agent = Mechanize.new
page = agent.get("http://www.google.com/")
agent.cookies

Jesus.
This topic is locked and can not be replied to.