Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Mechanize Page to String

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

like image 572
Rich_F Avatar asked Dec 29 '25 21:12

Rich_F


1 Answers

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
like image 199
JonB Avatar answered Jan 01 '26 11:01

JonB