How to get the page source with Mechanize/Nokogiri

Waley Chen picture Waley Chen · Jun 27, 2011 · Viewed 17.1k times · Source

I'm logged into a webpage/servlet using Mechanize.

I have a page object:

jobShortListPg = agent.get(addressOfPage)

When I use:

puts jobShortListPg

I get the "mechanized" version of the page which I don't want:

#<Mechanize::Page::Link "Home" "blahICScriptProgramName=WEBLIB_MENU.ISCRIPT3.FieldFormula.IScript_DrillDown&target=main0&Level=0&RL=&navc=3171">

How do I get the HTML source of the page instead?

Answer

Dogbert picture Dogbert · Jun 27, 2011

Use .body:

puts jobShortListPg.body