Browsing with Cookies

I am writing an app that takes in some basic data and then scours some known Internet locations for more data relevant to the input.

One of them relys on cookies to get the data in a form I can use. Net::HTTP appears not to use cookies, even if you're inside the same .start block.

Does open-uri offer cookies? I was under the impression that it was more of a wrapper.

Is there a way to provide a cookie? I could likely synthesize the information that the server was looking for.

Cheers,

Jim

WWW::Mechanize provides cookies, and may be a better solution for your application anyway. It parses HTML and handles context, unlike the lower-level Net::HTTP.

You can get it as a gem named 'mechanize', or from: http://www.ntecs.de/blog/Blog/WWW-Mechanize.rdoc

···

On May 25, 2005, at 6:30 AM, Jim Van Fleet wrote:

One of them relys on cookies to get the data in a form I can use. Net::HTTP appears not to use cookies, even if you're inside the same .start block.

--
John Labovitz
Macintosh support, research, and software development
John Labovitz Consulting, LLC
johnl@johnlabovitz.com | +1 503.949.3492 | www.johnlabovitz.com/consulting

I posted a solution to this as an example in the rails wiki; see

http://wiki.rubyonrails.com/rails/show/ExampleCookieJarHelper

and

http://wiki.rubyonrails.com/rails/show/HowToRenderProxiedPages

--MarkusQ

···

On Wed, 2005-05-25 at 06:30, Jim Van Fleet wrote:

I am writing an app that takes in some basic data and then scours some
known Internet locations for more data relevant to the input.

One of them relys on cookies to get the data in a form I can use.
Net::HTTP appears not to use cookies, even if you're inside the same
.start block.

Does open-uri offer cookies? I was under the impression that it was
more of a wrapper.

Is there a way to provide a cookie? I could likely synthesize the
information that the server was looking for.

Cheers,

Jim

Hi,

Jim Van Fleet wrote:

I am writing an app that takes in some basic data and then scours some
known Internet locations for more data relevant to the input.

One of them relys on cookies to get the data in a form I can use.
Net::HTTP appears not to use cookies, even if you're inside the same
.start block.

Does open-uri offer cookies? I was under the impression that it was
more of a wrapper.

Is there a way to provide a cookie? I could likely synthesize the
information that the server was looking for.

I know you already found the way... But FYI and ADV.

Type "http cookie" at the right top corner box of RAA
(http://raa.ruby-lang.org/\) to find http-access2. Here's a sample:
http://raa.ruby-lang.org/gonzui/markup/http-access2/sample/howto.rb

Regards,
// NaHi

Markus wrote:

I posted a solution to this as an example in the rails wiki; see

http://wiki.rubyonrails.com/rails/show/ExampleCookieJarHelper

and

http://wiki.rubyonrails.com/rails/show/HowToRenderProxiedPages

--MarkusQ

For those in the future who stumble upon this thread, it was a hacked to death version of this solution that worked for me. I had to hack the cookie jar so that it worked on only the root domain, as it was a domain wide cookie that I needed to use.

WWW:Mechanize looks awesome, but at this time isn't really useable for me. I have enough trouble on my plate without having to maintain my installation of ruby-current; 1.8.2 is not new enough.

Since this solution did work, I'm sure I could study the problem and come up with something better based on the RFC, but I think I'll stick with what I've got.

Cheers,

Jim

···

On Wed, 2005-05-25 at 06:30, Jim Van Fleet wrote: