Browsing with Cookies

J

Jim Van Fleet

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
 
J

John Labovitz

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.

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

--
John Labovitz
Macintosh support, research, and software development
John Labovitz Consulting, LLC
(e-mail address removed) | +1 503.949.3492 | www.johnlabovitz.com/
consulting
 
M

Markus

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

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
 
J

Jim Van Fleet

Markus said:
On Wed, 2005-05-25 at 06:30, Jim Van Fleet 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
 
N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFCmc/sf6b33ts2dPkRAseuAKCfESqMzXzJWERQvrGYavESr0NNPgCgyypY
z4q1Fr2jLIfxSbQkr66htuM=
=2hOd
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top