3

I have captured a Mechanize page. How can I get that item into a string? Pretty Print is used to output that object, however I'd like to get that into a string for further instructions. I can't seem to find any method.

Any advice appreciated.

Cheers

Rich_F
  • 1,830
  • 3
  • 24
  • 45
  • @sawa Like I said, it's a Mechanize Page. That is an object. I can Pretty Print that object, and it outputs. Its object.class is a Mechanize::Page. I'd like to get that output into a string so I can use it elsewhere. But the class has no way of coercing that output into a string. An how his comment is gone. – Rich_F Jan 20 '15 at 01:25

1 Answers1

4

Never needed to save the page content to a string but this works:

require 'mechanize'
agent = Mechanize.new
page = agent.get("http://www.google.com")
s = page.content
JonB
  • 836
  • 1
  • 11
  • 15